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
https://forums.phpfreaks.com/topic/170832-solved-sql-syntax-problem/
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

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.

 

 

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.