Seaholme Posted July 12, 2010 Share Posted July 12, 2010 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! Quote Link to comment https://forums.phpfreaks.com/topic/207503-mysql-syntax-error/ Share on other sites More sharing options...
PFMaBiSmAd Posted July 12, 2010 Share Posted July 12, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/207503-mysql-syntax-error/#findComment-1084845 Share on other sites More sharing options...
bh Posted July 12, 2010 Share Posted July 12, 2010 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) Quote Link to comment https://forums.phpfreaks.com/topic/207503-mysql-syntax-error/#findComment-1084848 Share on other sites More sharing options...
Seaholme Posted July 12, 2010 Author Share Posted July 12, 2010 Thanks so much guys. Unfortunately I've put this variable in multiple places already so I might have to go with the ugly solution, or go back and change tonnes of stuff! Quote Link to comment https://forums.phpfreaks.com/topic/207503-mysql-syntax-error/#findComment-1084850 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.