Eggzorcist Posted August 18, 2009 Share Posted August 18, 2009 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 More sharing options...
kickstart Posted August 18, 2009 Share Posted August 18, 2009 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 https://forums.phpfreaks.com/topic/170832-solved-sql-syntax-problem/#findComment-900939 Share on other sites More sharing options...
PFMaBiSmAd Posted August 18, 2009 Share Posted August 18, 2009 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 https://forums.phpfreaks.com/topic/170832-solved-sql-syntax-problem/#findComment-900945 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.