I am using this code below to create a table in database <?php $id=$_POST['id']; $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } //Create Table For Catagory mysql_select_db("test",$con); $sql = "CREATE TABLE $id ( FirstName varchar(15), LastName varchar(15), Age int )"; // Execute query mysql_query($sql,$con); ?> Code (markup): It is not working as I used a variable as table name.How can I use a variable as table name when creating new table?
It should work perfectly fine using $id. Change mysql_query($sql,$con); to $result = mysql_query($sql); If it still doesn't work, add in: echo $sql; and paste the resulting query here.
Thanks for ur reply.But it's not working,The resulting query is CREATE TABLE details { FirstName varchar(15), LastName varchar(15), Age int } Code (markup):