Jump to content

SQL Error


xyn

Recommended Posts

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]
Link to comment
https://forums.phpfreaks.com/topic/13590-sql-error/
Share on other sites

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().
Link to comment
https://forums.phpfreaks.com/topic/13590-sql-error/#findComment-52668
Share on other sites

$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())";
Link to comment
https://forums.phpfreaks.com/topic/13590-sql-error/#findComment-52675
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.