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