AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Teh Fears of MySQL (https://forums.alliedmods.net/showthread.php?t=10517)

TotalNoobScripter 02-21-2005 19:18

Teh Fears of MySQL
 
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.

Twilight Suzuka 02-21-2005 19:19

erm.... I assume you ended the code block with a } right?

TotalNoobScripter 02-21-2005 19:21

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 02-22-2005 09:02

bumpzorz

XxAvalanchexX 02-22-2005 16:11

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.

Johnny got his gun 02-22-2005 17:11

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

XxAvalanchexX 02-22-2005 18:56

And note the apostrophes by JGHG. :-)

TotalNoobScripter 02-22-2005 20:37

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?

Johnny got his gun 02-23-2005 03:06

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.


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

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