Jump to content

[SOLVED] dont understand this error


Woodburn2006

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.]

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.