Jump to content

MySQL query needed


discorevilo

Recommended Posts

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

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

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

[!--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

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.