mySQL misery.
-
Age of Fable
- Posts: 54
- Joined: Fri Feb 19, 2010 6:37 am
mySQL misery.
I can't see the syntax error in this, but apparently there is one. Can anyone help?
UPDATE current SET key='yqsfod' WHERE email='news@apolitical.info'
(I've checked that current is a database, with a field email, and one of those fields has the value news@apolitical.info)
UPDATE current SET key='yqsfod' WHERE email='news@apolitical.info'
(I've checked that current is a database, with a field email, and one of those fields has the value news@apolitical.info)
Easy to play - hard to survive. http://www.ageoffable.net
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: mySQL misery.
there is a field call key?
and when you say a database named current, you mean a table named current right?
what is the exact error and can we see more of the code?
and when you say a database named current, you mean a table named current right?
what is the exact error and can we see more of the code?
-
Age of Fable
- Posts: 54
- Joined: Fri Feb 19, 2010 6:37 am
Re: mySQL misery.
Yes, 'current' is a table.
This is the output:
Invalid query: 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 'key='tsosit' WHERE email='news@apolitical.info'' at line 1
Whole query: UPDATE current SET key='tsosit' WHERE email='news@apolitical.info'
I've checked $link, and it's the same as it is on other pages which work.
Code: Select all
$ok=1;
$key="";
for ($z=1;$z<=6;$z++) {
$key=$key.chr(rand(97,122));
}
$qry="UPDATE current SET key='".$key."' WHERE email='".$emailadd."'";
$result=mysql_query($qry,$link);
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= '<br>Whole query: ' . $qry;
die($message);
}Invalid query: 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 'key='tsosit' WHERE email='news@apolitical.info'' at line 1
Whole query: UPDATE current SET key='tsosit' WHERE email='news@apolitical.info'
I've checked $link, and it's the same as it is on other pages which work.
Easy to play - hard to survive. http://www.ageoffable.net
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: mySQL misery.
Code: Select all
$qry="UPDATE current SET key='$key' WHERE email='$emailadd'";-
Age of Fable
- Posts: 54
- Joined: Fri Feb 19, 2010 6:37 am
Re: mySQL misery.
That had the same output:
Invalid query: 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 'key='dozxop' WHERE email='news@apolitical.info'' at line 1
Whole query: UPDATE current SET key='dozxop' WHERE email='news@apolitical.info'
Invalid query: 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 'key='dozxop' WHERE email='news@apolitical.info'' at line 1
Whole query: UPDATE current SET key='dozxop' WHERE email='news@apolitical.info'
Easy to play - hard to survive. http://www.ageoffable.net
Re: mySQL misery.
'key' is a reserved word in SQL, you will need to either call it a different field name or use proper quotation:
Code: Select all
UPDATE `current` SET `key`='$key' WHERE `email`='$emailadd';
Fighting for peace is declaring war on war. If you want peace be peaceful.
-
Age of Fable
- Posts: 54
- Joined: Fri Feb 19, 2010 6:37 am
Re: mySQL misery.
I added quotes to 'key', but that didn't change the result.
Invalid query: 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 ''key'='cjgzeq' WHERE email='news@apolitical.info'' at line 1
Whole query: UPDATE current SET 'key'='cjgzeq' WHERE email='news@apolitical.info'
Invalid query: 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 ''key'='cjgzeq' WHERE email='news@apolitical.info'' at line 1
Whole query: UPDATE current SET 'key'='cjgzeq' WHERE email='news@apolitical.info'
Easy to play - hard to survive. http://www.ageoffable.net
Re: mySQL misery.
You want the ` quotes, not the ' ones, there is a difference between them 
--- Game Database ---
For all your game information needs!
Visit us at: http://www.gamedatabase.eu today!
For all your game information needs!
Visit us at: http://www.gamedatabase.eu today!
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: mySQL misery.
ah man I cant believe i missed that! yeah do not use key at all. I have had the same problem with other key words. Change the word key to something else.
-
Age of Fable
- Posts: 54
- Joined: Fri Feb 19, 2010 6:37 am
Re: mySQL misery.
Thanks, it's now working.
Easy to play - hard to survive. http://www.ageoffable.net