Raised This Month: $ Target: $400
 0% 

Teh Fears of MySQL


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
TotalNoobScripter
Senior Member
Join Date: Aug 2004
Old 02-21-2005 , 19:18   Teh Fears of MySQL
Reply With Quote #1

Code:
new authid[32], vaultstring[256];   new query[256]     get_user_authid(id,authid,31)             if (mySql == SQL_OK) {         new savewages, savemoney, savebank, savepayroll         new savejob[32]         savewages = employedwages[id]         savemoney = usermoney[id]         savebank = userbank[id]         savepayroll = employedpayroll[id]         format(savejob,31,"%s",employedjob[id])                     format(query,255,"UPDATE economy SET wages=%i WHERE steamid = %s",savewages,authid);     result = dbi_query(mySql,query);     dbi_free_result ( result )         format(query,255,"UPDATE economy SET money=%i WHERE steamid = %s",savemoney,authid);     result = dbi_query(mySql,query);     dbi_free_result ( result )          format(query,255,"UPDATE economy SET bank=%i WHERE steamid = %s",savebank,authid);     result = dbi_query(mySql,query);     dbi_free_result ( result )         format(query,255,"UPDATE economy SET job='%s' WHERE steamid = %s",savejob,authid);     result = dbi_query(mySql,query);     dbi_free_result ( result )         format(query,255,"UPDATE economy SET companyroll=%i WHERE steamid = %s",savepayroll,authid);     result = dbi_query(mySql,query);     dbi_free_result ( result )

anyone see wtf is wrong with this? its like, not makign changes to the mysql database.
TotalNoobScripter is offline
Send a message via AIM to TotalNoobScripter
Twilight Suzuka
bad
Join Date: Jul 2004
Location: CS lab
Old 02-21-2005 , 19:19  
Reply With Quote #2

erm.... I assume you ended the code block with a } right?
__________________
Twilight Suzuka is offline
Send a message via AIM to Twilight Suzuka Send a message via MSN to Twilight Suzuka
TotalNoobScripter
Senior Member
Join Date: Aug 2004
Old 02-21-2005 , 19:21  
Reply With Quote #3

yes, theres just stuff underneath and above that are totaly not related to the problem.

also the fact that ive never done anything dbi before. I like mysql_* better, but it was updated.
TotalNoobScripter is offline
Send a message via AIM to TotalNoobScripter
TotalNoobScripter
Senior Member
Join Date: Aug 2004
Old 02-22-2005 , 09:02  
Reply With Quote #4

bumpzorz
TotalNoobScripter is offline
Send a message via AIM to TotalNoobScripter
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 02-22-2005 , 16:11  
Reply With Quote #5

Okay... let's say savewages is equal to 4 and authid is equal to 1337. So MySQL is interpreting it like this:

Update the table, setting their wages (column) value is the same as the 4 (column) value where their steamid (column) is equal to the value of 1337 (column).

Now, if you put apostrophes around your values, interprets it like this:

Update the table, setting their wages (column) to 4 where their steamid is equal to 1337.

When you don't put apostrophes around it like that MySQL thinks you are referring to the name of a colum and gets the value from that column. In this case, the column it is trying to look for doesn't exist, so it can't updating the results correctly.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
Johnny got his gun
Veteran Member
Join Date: Jan 2004
Location: Tokyo
Old 02-22-2005 , 17:11  
Reply With Quote #6

Quote:
"UPDATE economy SET wages=%i WHERE steamid = %s"
"UPDATE economy SET money=%i WHERE steamid = %s"
can be puttogetherized like this:

Code:
"UPDATE economy SET wages = '%i', money = '%i' WHERE steamid = '%s'"
Johnny got his gun is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 02-22-2005 , 18:56  
Reply With Quote #7

And note the apostrophes by JGHG. :-)
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
TotalNoobScripter
Senior Member
Join Date: Aug 2004
Old 02-22-2005 , 20:37  
Reply With Quote #8

i had a bad incident when putting stuff together in mysql with mysql_* before. By any chance can dbi querys 'puttogetherize' 5 querys, as mysql_* could only handle 3 without lagging?
TotalNoobScripter is offline
Send a message via AIM to TotalNoobScripter
Johnny got his gun
Veteran Member
Join Date: Jan 2004
Location: Tokyo
Old 02-23-2005 , 03:06  
Reply With Quote #9

That's not puttogetherizing queries, it's puttogetherizing several field updates. I also recently noticed MySql module apparantly doesn't like using several semicolon queries in one dbi_query() call.
Johnny got his gun is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 14:09.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode