xyn Posted July 3, 2006 Share Posted July 3, 2006 Hey Guys!Can someone tell me what's wrong with my SQL Code, I've checked the code and can't spot an error so it's probably my eyes.MYSQL_ERROR();[color=red]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 '' at line 16[/color][code=php:0]mysql_query("INSERT INTO profile (user, age, fav_music, fav_band, fav_song, hat_music, hat_band, hat_song, fir_album, fir_single, fir_gig, interests, stats, rated, date, time) VALUES ('".strtolower($usrnam)."', '".$_POST[age]."', '".$_POST[fav_music]."', '".$_POST[fav_band]."', '".$_POST[fav_song]."', '".$_POST[hat_music]."', '".$_POST[hat_band]."', '".$_POST[hat_song]."', '".$_POST[fir_album]."', '".$_POST[fir_single]."', '".$_POST[fir_gig]."', '".$_POST[interests]."', '".$_POST[stats]."', '0', '$date', '$time'") or die(mysql_error());[/code] Quote Link to comment https://forums.phpfreaks.com/topic/13590-sql-error/ Share on other sites More sharing options...
xyn Posted July 3, 2006 Author Share Posted July 3, 2006 I've done it now Lol. mist the connection string...and a spelling error Quote Link to comment https://forums.phpfreaks.com/topic/13590-sql-error/#findComment-52667 Share on other sites More sharing options...
JayBachatero Posted July 3, 2006 Share Posted July 3, 2006 Try this.[code]mysql_query(" INSERT INTO profile (user, age, fav_music, fav_band, fav_song, hat_music, hat_band, hat_song, fir_album, fir_single, fir_gig, interests, stats, rated, date, time) VALUES ( '" .strtolower($usrnam) ."', '$_POST[age]', '$_POST[fav_music]', '$_POST[fav_band]', '$_POST[fav_song]', '$_POST[hat_music]', '$_POST[hat_band]', '$_POST[hat_song]', '$_POST[fir_album]', '$_POST[fir_single]', '$_POST[fir_gig]', '$_POST[interests]', '$_POST[stats]', '0', '$date', '$time')") or die(mysql_error());[/code]Also you should look into addslashes(). Quote Link to comment https://forums.phpfreaks.com/topic/13590-sql-error/#findComment-52668 Share on other sites More sharing options...
effigy Posted July 3, 2006 Share Posted July 3, 2006 [quote author=JayBachatero link=topic=99345.msg391205#msg391205 date=1151962950]Also you should look into addslashes().[/quote]...or use MySQL's real_escape_string to prevent injection attacks. Quote Link to comment https://forums.phpfreaks.com/topic/13590-sql-error/#findComment-52674 Share on other sites More sharing options...
redarrow Posted July 3, 2006 Share Posted July 3, 2006 $query="INSERT INTO profile (user, age, fav_music, fav_band, fav_song, hat_music, hat_band, hat_song, fir_album, fir_single, fir_gig, interests, stats, rated, date, time) VALUES ('$usrnam','$age','$fav_music','$fav_band','$fav_song','$hat_music','$hat_band','$hat_song','$fir_album','$fir_single],'$fir_gig','$interests','$stats]','0','$date','$time'") or die(mysql_error())"; Quote Link to comment https://forums.phpfreaks.com/topic/13590-sql-error/#findComment-52675 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.