joecooper Posted March 11, 2006 Share Posted March 11, 2006 <?phpsession_start();include("db.php");echo "Your username:$username, Your key:$key";mysql_query("UPDATE users SET active='yes' WHERE key='$key'");?>i have this code, the db.php file is fine, the $key and $username varibles come from the link, that allworks, but it doesnt want to update the feild "active". the keys match ect. im not sure what to try Quote Link to comment Share on other sites More sharing options...
AndyB Posted March 11, 2006 Share Posted March 11, 2006 sighI bet if you echo'd the mysql_error() you would get a clue what the problem is. Quote Link to comment Share on other sites More sharing options...
joecooper Posted March 11, 2006 Author Share Posted March 11, 2006 very true :)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=''' at line 1wtf does that mean? Quote Link to comment Share on other sites More sharing options...
joecooper Posted March 11, 2006 Author Share Posted March 11, 2006 i have this code on another page, and it works fine:mysql_query ("UPDATE 4x4page SET title='$title', info='$info', picture='$picture', price='$price' WHERE id='$id' ");i cannot find anything wrong with it! Quote Link to comment Share on other sites More sharing options...
AndyB Posted March 12, 2006 Share Posted March 12, 2006 Hint: Don't use reserved words for table names or field names.[b]key[/b] [a href=\"http://www.htmlite.com/mysql002a.php\" target=\"_blank\"]is in the list of reserved words[/a] <- good bookmark Quote Link to comment Share on other sites More sharing options...
joecooper Posted March 12, 2006 Author Share Posted March 12, 2006 argh! i really should use a prefix for all my scripts Quote Link to comment Share on other sites More sharing options...
keeB Posted March 12, 2006 Share Posted March 12, 2006 [!--quoteo(post=354059:date=Mar 12 2006, 01:40 AM:name=joecooper)--][div class=\'quotetop\']QUOTE(joecooper @ Mar 12 2006, 01:40 AM) [snapback]354059[/snapback][/div][div class=\'quotemain\'][!--quotec--]argh! i really should use a prefix for all my scripts[/quote]if you're going to use a reserved word.. you could encapsulate it like [code]select * from users where [key] = '1'[/code] Quote Link to comment Share on other sites More sharing options...
saiko Posted March 12, 2006 Share Posted March 12, 2006 mysql_query("UPDATE users SET active='yes' WHERE key='$key'");i suggest use `` located next to the number 1mysql_query("UPDATE `users` SET `active`='yes' WHERE `key`='$key'");a problem i had a while back :D Quote Link to comment Share on other sites More sharing options...
joecooper Posted March 12, 2006 Author Share Posted March 12, 2006 Thannks all!, ive changed the feild name in the database in the end! thanks ever so much. Quote Link to comment 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.