Jump to content

Recommended Posts

i get this error everytime i do a bit of code:

 

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 'group, group_position) VALUES (Gosport,2007-11-21,Roger Calton,1,eg - 32:875,13,' at line 1

 

the code that is executing is:

 

$driver = $_POST['driver'];
		$groupnumber = $_POST['groupnumber'];
		$grouppos = $_POST['grouppos'];
		$lap = $_POST['lap'];
		$position = $_POST['position'];

		foreach($driver as $a){
		$b = current($groupnumber);
		$c = current($grouppos);
		$d = current($lap);
		$e = current($position);
		$track = $_POST['track'];
		$date = date('Y-m-d', $_POST['date']);
		$query = mysql_query("INSERT INTO results (track, date, driver, race_position, time, group, group_position) VALUES ($track,$date,$a,$e,$d,$c,$b)") or die(mysql_error());
		mysql_query($query, $connection);
		next ($groupnumber);
		next ($grouppos);
		next ($lap);
		next ($position);
		}

 

any ideas to why this is happening?

Link to comment
https://forums.phpfreaks.com/topic/78236-solved-dont-understand-this-error/
Share on other sites

This line....

 

$query = mysql_query("INSERT INTO results (track, date, driver, race_position, time, group, group_position) VALUES ($track,$date,$a,$e,$d,$c,$b)") or die(mysql_error());

 

Should be....

 

$query = "INSERT INTO results (track, date, driver, race_position, time, group, group_position) VALUES ('$track','$date','$a','$e','$d','$c','$b')";

 

And, this line....

 

mysql_query($query, $connection);

 

should be....

 

mysql_query($query, $connection) || die(mysql_error());

i made the changes you told me to do but i still get this error still:

 

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 'group, group_position) VALUES ('Gosport','2007-11-21','Roger Calton','1','eg - 3' at line 1
syntax to use near 'group
The portion of the query right after single-quote in the error that mysql outputs is the point where it found something it cannot figure out. GROUP is a reserved keyword. [From the previous post - time is a data type, not a reserved keyword and it is permitted to be used as a column name.]
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.