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 ?

16th Nov 2016, 3:19 AM
Bilal saeed
Bilal saeed - avatar
3 Answers
0
Please post error and snippet of your code.
16th Nov 2016, 4:03 AM
Nagendra Prajwal
Nagendra Prajwal - avatar
0
can you show your connector file code and its error
16th Nov 2016, 6:01 AM
Aditya kumar pandey
Aditya kumar pandey - avatar
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 !!
16th Nov 2016, 3:01 PM
Bilal saeed
Bilal saeed - avatar