Jump to content

MySQL syntax error...


Seaholme

Recommended Posts

Hi there,

 

I've no idea how this broke, but somehow I've managed to generate an error in this and I have no idea what's wrong to go about fixing it :(

 

This is the error I get

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 'INT, TBY) VALUES ('Name', 'Gender', 'Breed', 'Region', '07/12/10'' at line 1

 

// Finally, create the record.
$newDog = @mysql_query("INSERT INTO dogs (name, gender, breed, region, date, owner, trait1, trait2, agree, STR, SPD, END, HRD, TFA, AGI, SND, FIT, INT, TBY) VALUES ('$name', '$gender', '$breed', '$region', '$date', $owner, '$trait1', '$trait2', '$agreeableness', '$high', '$verylow', '$high2', '$veryhigh', '$low', '$TFA', '$low2', '$SND', '$FIT', '$medium')") or die("Error: ".mysql_error());

 

I've looked particularly in the area it's complaining about, but no success :/

 

Does anybody have any idea why it might not be working?

 

Just in case this helps, I had no errors in this until I added in the following variables:

$verylow = rand(10, 13); 
$low = rand(13, 16);
$low2 = rand(13, 16);
$medium = rand(16, 21); 
$high = rand(21, 25);
$high2 = rand(21, 25); 
$veryhigh = rand(25, 30); 
$TFA = rand(15, 70);
$SND = rand(60, 90);
$FIT = '50';

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/207503-mysql-syntax-error/
Share on other sites

The point in the query that the error is calling your attention to INT is a reserved key word - http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html

 

Either rename your column to something else or enclose it in back-ticks `` every time you use it as a column name in a query.

Link to comment
https://forums.phpfreaks.com/topic/207503-mysql-syntax-error/#findComment-1084845
Share on other sites

Yeah its not recommended as name type names (int, varchar...).

 

But heres an ugly solution (dont use it, rather rename the column): INSERT INTO dogs ( ... `int` ... ) VALUES (...

If you use altgr+7 (i dont know the character name) it will works.

 

sorry, i wasnt mindful (PFMaBiSmAd ~wrote the same)

Link to comment
https://forums.phpfreaks.com/topic/207503-mysql-syntax-error/#findComment-1084848
Share on other sites

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.