big-dog1965 Posted February 19, 2009 Share Posted February 19, 2009 I have a php file that creats table and is suppost to insert some data into one of the tables it creats the table fine but doesnt insert and it doesnt give an error here is the table and the insert portion, can someone help me here Thanks echo '<p>Creating table login'; if(!$result = mysql_query('CREATE TABLE IF NOT Exists login ( userid int(35) NOT NULL auto_increment , user_name varchar(50) NOT NULL , user_pass varchar(255) NOT NULL , user_level varchar(50) NOT NULL , `date` varchar(20) default NULL , user_email varchar(50) NOT NULL , user_ip varchar(50) NOT NULL , PRIMARY KEY (userid) )')) { echo ' Error creating Table ' . mysql_error(); } echo '<p>Inserting admin data into table Login'; mysql_query('INSERT INTO Login VALUES ( "","admin","21232f297a57a5a743894a0e4a801fc3","4","02-19-2009","Admin@bigtop.com","" )'); Quote Link to comment https://forums.phpfreaks.com/topic/146022-solved-inserting-data-into-mysql-with-php/ Share on other sites More sharing options...
premiso Posted February 19, 2009 Share Posted February 19, 2009 <?php echo '<p>Creating table login'; $result = mysql_query('CREATE TABLE IF NOT Exists login ( userid int(35) NOT NULL auto_increment , user_name varchar(50) NOT NULL , user_pass varchar(255) NOT NULL , user_level varchar(50) NOT NULL , `date` varchar(20) default NULL , user_email varchar(50) NOT NULL , user_ip varchar(50) NOT NULL , PRIMARY KEY (userid) )') or die(mysql_error()); echo '<p>Inserting admin data into table Login'; mysql_query("INSERT INTO Login VALUES ('','admin','21232f297a57a5a743894a0e4a801fc3','4','02-19-2009','Admin@bigtop.com','' )") or die(mysql_error()); A: mysql uses single quotes not double quotes (your query had double quotes.) B: use the die(mysql_error()) to spit out "decent" error messages upon an error (since I take it this is an install script that should be fine.). Quote Link to comment https://forums.phpfreaks.com/topic/146022-solved-inserting-data-into-mysql-with-php/#findComment-766581 Share on other sites More sharing options...
revraz Posted February 19, 2009 Share Posted February 19, 2009 Is the table name Login or login? Also, don't set your DATE field as a VARCHAR, use a Date type and store it properly. Quote Link to comment https://forums.phpfreaks.com/topic/146022-solved-inserting-data-into-mysql-with-php/#findComment-766583 Share on other sites More sharing options...
premiso Posted February 19, 2009 Share Posted February 19, 2009 Is the table name Login or login? Just fyi, mysql "should" be case insensitive on that kind of stuff Quote Link to comment https://forums.phpfreaks.com/topic/146022-solved-inserting-data-into-mysql-with-php/#findComment-766590 Share on other sites More sharing options...
big-dog1965 Posted February 19, 2009 Author Share Posted February 19, 2009 Great job guys l and L are most definitely the problem and the “ was jacked as well Thanks Quote Link to comment https://forums.phpfreaks.com/topic/146022-solved-inserting-data-into-mysql-with-php/#findComment-766613 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.