Jump to content


Photo

MySQL query needed


  • Please log in to reply
4 replies to this topic

#1 discorevilo

discorevilo
  • Members
  • Pip
  • Newbie
  • 9 posts

Posted 30 May 2006 - 12:37 PM

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
UPDATE `nuke_users` SET `chall_web`=chall_web+1  WHERE `user_id` = `2`

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
 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'

soo does anyone know how i can fix this


#2 discorevilo

discorevilo
  • Members
  • Pip
  • Newbie
  • 9 posts

Posted 30 May 2006 - 02:29 PM

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

#3 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 31 May 2006 - 06:37 AM

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.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#4 vishi83

vishi83
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 31 May 2006 - 11:32 AM

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



#5 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 31 May 2006 - 05:01 PM

[!--quoteo(post=378671:date=May 31 2006, 07:32 AM:name=vishi)--][div class=\'quotetop\']QUOTE(vishi @ May 31 2006, 07:32 AM) View Post[/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!

UPDATE nuke_users SET chall_web = chall_web + 1 WHERE user_id = '2';

Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users