Jump to content

Problem in Create a Database Table using SQL and PHP


varun7952

Recommended Posts

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.