Jump to content

Archived

This topic is now archived and is closed to further replies.

discorevilo

MySQL query needed

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

Share this post


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

Share this post


Link to post
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.

Share this post


Link to post
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\" /]

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites

×

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.