0
How do i create a database table through php?
whenever i try to connwct a database with a php file it gives error. can anyone guide me ?
3 Answers
0
Please post error and snippet of your code.
0
can you show your connector file code and its error
0
<?php
$host='localhost';
$username='root';
$password="";
$Dbname= "myDb";
$connect=mysqli_connect($host,$username,$password,$dbname);
If(!$connect){
Die("connection failed".mysqli_connect_error());
}
$sql="create table students(id int(6) primary key , firstname varchar(30) not null, lastname varchar(30) not null, email varchar(50) )";
If(mysqli_query($connect,$sql){
Echo "table created successfully";
}
Else {
Echo "error creating table".mysqli_error($connect);
}
Mysqli_close($connect);
?>
it doesn't recognizes the database !!