discorevilo Posted May 30, 2006 Share Posted May 30, 2006 i am trying to put a challenges system into my website but i dont know MySQL well enought to make the query... a friend told me that this would work [code]UPDATE `nuke_users` SET `chall_web`=chall_web+1 WHERE `user_id` = `2`[/code] then i could just change user_id = 2 into user_id = '".intval($cookie[0])."' but when i went into phpMyAdmin and tryed to query that it gave me this [code] SQL query: UPDATE `nuke_users` SET `chall_web` = chall_web +1 WHERE `user_id` = `2` MySQL said: Documentation #1054 - Unknown column '2' in 'where clause' [/code] soo does anyone know how i can fix this Link to comment https://forums.phpfreaks.com/topic/10770-mysql-query-needed/ Share on other sites More sharing options...
discorevilo Posted May 30, 2006 Author Share Posted May 30, 2006 ok UPDATE `nuke_users` SET chall_web=chall_web+1 WHERE user_id= 2; works in the phpMyAdmin but can someone post how it needs to be put so that i can use it from a webpage Link to comment https://forums.phpfreaks.com/topic/10770-mysql-query-needed/#findComment-40248 Share on other sites More sharing options...
fenway Posted May 31, 2006 Share Posted May 31, 2006 There's no "difference" between a PHP call to a MySQL query from a PHP page or PHPMyAdmin -- it's all the same thing. The real issue was that you were backticking a string literal -- `2` -- when you meant '2'. In general, though everyone likes to backtick everything, it's a really, really bad idea. Dont' do it. Let MySQL complain when you use a reserved keyword, and then you won't ever need them. Link to comment https://forums.phpfreaks.com/topic/10770-mysql-query-needed/#findComment-40470 Share on other sites More sharing options...
vishi83 Posted May 31, 2006 Share Posted May 31, 2006 Jus follow query conventions;UPDATE NUKE_USERS SET CHALL_WEB = CHALL_WEB + 1 WHERE USER_ID = 2;Query in Upper case and follow this consistently throughout your application.Thanks. [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /] Link to comment https://forums.phpfreaks.com/topic/10770-mysql-query-needed/#findComment-40526 Share on other sites More sharing options...
fenway Posted May 31, 2006 Share Posted May 31, 2006 [!--quoteo(post=378671:date=May 31 2006, 07:32 AM:name=vishi)--][div class=\'quotetop\']QUOTE(vishi @ May 31 2006, 07:32 AM) [snapback]378671[/snapback][/div][div class=\'quotemain\'][!--quotec--]Jus follow query conventions;UPDATE NUKE_USERS SET CHALL_WEB = CHALL_WEB + 1 WHERE USER_ID = 2;Query in Upper case and follow this consistently throughout your application.Thanks. [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /][/quote]Please don't EVER do this -- use upper-case for keywords, and nothing else![code]UPDATE nuke_users SET chall_web = chall_web + 1 WHERE user_id = '2';[/code] Link to comment https://forums.phpfreaks.com/topic/10770-mysql-query-needed/#findComment-40620 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.