Jump to content

[SOLVED] SQL syntax Problem...


Eggzorcist

Recommended Posts

I'm not sure what's causing this, but I'm getting this 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 'JPFoster','Club name ID' ,Tester', '08/06/2009', 'Thursday, 6 August, 2009', '22' at line 3

 

Here's my query

 

"INSERT INTO events

(user, clubname, name, fromslashes, fromdisplay, fromtime, toslashes, todisplay, totime, quickdescription, pagedescription, status) VALUES

(''".$_GET['USER']."','".$_GET['clubname']."' ,".$data['eventTitle']."', '".$data['from1']."', '".$data['from2']."', '".$data['fromtime']."', '".$data['to1']."', '".$data['to2']."', '".$data['totime']."', '".$data['quickDesc']."', '".$data['description']."', '".$status."')"

Link to comment
Share on other sites

Hi

 

You have an extra quote:-

 

"INSERT INTO events

              (user, clubname, name, fromslashes, fromdisplay, fromtime, toslashes, todisplay, totime, quickdescription, pagedescription, status) VALUES

              (''".$_GET['USER']."','".$_GET['clubname']."' ,".$data['eventTitle']."', '".$data['from1']."', '".$data['from2']."', '".$data['fromtime']."', '".$data['to1']."', '".$data['to2']."', '".$data['totime']."', '".$data['quickDesc']."', '".$data['description']."', '".$status."')"

 

All the best

 

Keith

Link to comment
Share on other sites

And this is at least the second thread concerning a syntax problem with quotes in your query.

 

Using the "','".$variable."','" syntax is extremely error prone and difficult to see syntax errors in (otherwise you could probably have found them yourself.)

 

I recommend using the least number of transitions/different elements in a string -

 

"INSERT INTO events
               (user, clubname, name, fromslashes, fromdisplay, fromtime, toslashes, todisplay, totime, quickdescription, pagedescription, status) VALUES
               ('{$_GET['USER']}','{$_GET['clubname']}','{$data['eventTitle']}','{$data['from1']}', '{$data['from2']}', '{$data['fromtime']}', '{$data['to1']}', '{$data['to2']}', '{$data['totime']}', '{$data['quickDesc']}', '{$data['description']}', '{$status}')"

 

And in going through that you left out a single-quote on one of the other values.

 

 

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.