Forum Moderators: coopster

Message Too Old, No Replies

MySQL Insert Error

Help debugging error

         

adammc

5:46 am on Mar 6, 2007 (gmt 0)

10+ Year Member



Hi Guys,

I can't for the life of me work out why I keep getting this error:

ERROR: 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 'WHERE username='billybob')' at line 76

[php]

$query = "INSERT INTO matrimonial (
username,
phone,
mobile,
createdby,
maritalstatus,
havechildren,
starsign,
height,
bodytype,
complexion,
specialcases,
bloodgroup,
religion,
tongue,
caste,
subcaste,
gotra,
manglik,
familyvalues,
educationlevel,
educationarea,
occupation,
annualincome,
diet,
smoke,
drink,
convenienttime,
contact_details_dislay_status,
family_father,
family_mother,
family_brother,
family_sister,
personality,
background,
date_reg,
profile_complete) VALUES (

'$_SESSION[username]',
'$phone',
'$mobile',
'$createdby',
'$maritalstatus',
'$havechildren',
'$starsign',
'$height',
'$bodytype',
'$complexion',
'$specialcases',
'$bloodgroup',
'$religion',
'$tongue',
'$caste',
'$subcaste',
'$gotra',
'$manglik',
'$familyvalues',
'$educationlevel',
'$educationarea',
'$occupation',
'$annualincome',
'$diet',
'$smoke',
'$drink',
'$convenienttime',
'$contact_details_dislay_status',
'$family_father',
'$family_mother',
'$family_brother',
'$family_sister',
'$personality',
'$background',
'$currentdatetime',
'1'

WHERE username='$_SESSION[username]')";

# execute SQL statement
$result = @mysql_query ($query);

# check for error
if (!$result) { echo("ERROR: " . mysql_error() . "\n$query\n");

// Show errors, if any
ini_set ('display_errors', 1);
error_reporting (E_ALL & ~E_NOTICE);

}

[/php]

Can anyone possibly help?
[/php]

cameraman

5:57 am on Mar 6, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No closing parenthesis at the end of the values list.

grandpa

6:00 am on Mar 6, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



After a quick look, shouldn't this '1'

be this '1')

cameraman beat me to it. I never have liked those SQL error messages, they can be ambiguous at times.

adammc

6:15 am on Mar 6, 2007 (gmt 0)

10+ Year Member



Thanks for your help guys :)

I also just worked out that I stupidly put in a WHERE clause on an INSERT statement!

It just proves that cutting and pasting code to save time doesnt always work out like that ;)