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
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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.