varun7952 Posted December 28, 2011 Share Posted December 28, 2011 i m tryin to create table from mysql coding and when i run the script its runs without any errors and just show that its created table but whn i chk into phpmyadmin i cnt find my table there and also when i use some copy paste from some website its just do the same thing but this time table is created but i cant find any difference between my table and the website table but still my script wont work please help me where is the mistake $connection=mysql_connect("127.0.0.1","root",""); $db=mysql_select_db("addressbook",$connection); if($db){ $SQL="CREATE TABLE address_data_new { ID int(7) NOT NULL auto_increment, First_name varchar(50) NOT NULL, ################## MY SCRIPT################ Last_name varchar(50) NOT NULL, email varchar(50) NOT NULL, PRIMARY KEY (ID), UNIQUE Id (ID) }"; /* $SQL="create table address_data { ID int(7) NOT NULL auto_increment, ############# working script############ First_Name varchar(50) NOT NULL, Surname varchar(50) NOT NULL, email varchar(50), PRIMARY KEY (ID), UNIQUE id (ID) )"; */ mysql_query($SQL); mysql_close($connection); echo "table added successfully"; } else { echo "database not found"; } ?> Link to comment https://forums.phpfreaks.com/topic/253985-problem-in-create-a-database-table-using-sql-and-php/ Share on other sites More sharing options...
trq Posted December 29, 2011 Share Posted December 29, 2011 Your overriding the $SQL variable so only the address_data table will ver be created. You will need to store your queries in two different variables then execute them both separately. Link to comment https://forums.phpfreaks.com/topic/253985-problem-in-create-a-database-table-using-sql-and-php/#findComment-1302048 Share on other sites More sharing options...
varun7952 Posted December 29, 2011 Author Share Posted December 29, 2011 but if i go with working script it works well i dont see aby difference between my script nd the working script please tell me where is the problem in these script Link to comment https://forums.phpfreaks.com/topic/253985-problem-in-create-a-database-table-using-sql-and-php/#findComment-1302112 Share on other sites More sharing options...
trq Posted December 30, 2011 Share Posted December 30, 2011 I already did. Link to comment https://forums.phpfreaks.com/topic/253985-problem-in-create-a-database-table-using-sql-and-php/#findComment-1302396 Share on other sites More sharing options...
varun7952 Posted December 30, 2011 Author Share Posted December 30, 2011 thx alot its wrkng now Link to comment https://forums.phpfreaks.com/topic/253985-problem-in-create-a-database-table-using-sql-and-php/#findComment-1302458 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.