brem13 Posted March 29, 2009 Share Posted March 29, 2009 hey, does anyone know what is wrong with this line? i use the EXACT same line in another page and i dont have a problem error Could not insert data because You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'values ('NULL', 'breminem', 'RE:Â test123', 'rewy', 'New', '2009-03-29 16:41:39'' at line 1 my database has 7 fields btw $insert = mysql_query("insert into $user values ('NULL', '$username', '$sub', '$message', 'New', '$dt2', '$dt2')") or die("Could not insert data because ".mysql_error()); Link to comment https://forums.phpfreaks.com/topic/151651-solved-mysql-error/ Share on other sites More sharing options...
ToonMariner Posted March 29, 2009 Share Posted March 29, 2009 Don't put quotes around NULL when you want auto_increment to work... 'NULL' is a string and mysql will treat it as such. Link to comment https://forums.phpfreaks.com/topic/151651-solved-mysql-error/#findComment-796395 Share on other sites More sharing options...
brem13 Posted March 29, 2009 Author Share Posted March 29, 2009 k, same error just no quotes around null Link to comment https://forums.phpfreaks.com/topic/151651-solved-mysql-error/#findComment-796397 Share on other sites More sharing options...
PFMaBiSmAd Posted March 29, 2009 Share Posted March 29, 2009 $user is probably empty. How about forming your query in a variable so that you can echo it to see what is in it. Link to comment https://forums.phpfreaks.com/topic/151651-solved-mysql-error/#findComment-796400 Share on other sites More sharing options...
brem13 Posted March 29, 2009 Author Share Posted March 29, 2009 ok, this is the line that should be posting the $user but its not posting it from the previous page, its blank <input type="hidden" name="user" value="<?php echo $user; ?>"> Link to comment https://forums.phpfreaks.com/topic/151651-solved-mysql-error/#findComment-796406 Share on other sites More sharing options...
PFMaBiSmAd Posted March 29, 2009 Share Posted March 29, 2009 When you do a "view source" of the form in your browser, is the value present? Link to comment https://forums.phpfreaks.com/topic/151651-solved-mysql-error/#findComment-796408 Share on other sites More sharing options...
brem13 Posted March 29, 2009 Author Share Posted March 29, 2009 yes Link to comment https://forums.phpfreaks.com/topic/151651-solved-mysql-error/#findComment-796416 Share on other sites More sharing options...
brem13 Posted March 29, 2009 Author Share Posted March 29, 2009 ok, i had a couple variables wrong in a different page, thanks guys, u got me on the right track Link to comment https://forums.phpfreaks.com/topic/151651-solved-mysql-error/#findComment-796417 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.