MySQL Query - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: MySQL Query (
/showthread.php?tid=165525)
[SOLVED] MySQL Query -
Agent Smith - 05.08.2010
Hello again
I'm working on a report command which is stored in a MySQL database, etc. But I have a problem with trying to identify report ID's.
pawn Код:
new query[126], strvalEx[126], result[126];
format(query,512,"SELECT `rid` FROM `reports` ORDER BY `id` DESC LIMIT 1;");
mysql_query(query);
mysql_store_result();
if(!mysql_num_rows())
{
playerinfo[playerid][report]=1;
}
else
{
while (mysql_fetch_row(result))
{
if((!strvalEx(result)%1000))
{
playerinfo[playerid][report]=1;
}
else
{
playerinfo[playerid][report]=strvalEx(result)+1;
}
}
}
I'm getting these errors:
Код:
C:\Documents and Settings\Admin\Desktop\World of GTA\test\gamemodes\test_new.pwn(1007) : error 012: invalid function call, not a valid address
C:\Documents and Settings\Admin\Desktop\World of GTA\test\gamemodes\test_new.pwn(1007) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Admin\Desktop\World of GTA\test\gamemodes\test_new.pwn(1007) : warning 215: expression has no effect
C:\Documents and Settings\Admin\Desktop\World of GTA\test\gamemodes\test_new.pwn(1007) : error 001: expected token: ";", but found ")"
C:\Documents and Settings\Admin\Desktop\World of GTA\test\gamemodes\test_new.pwn(1007) : fatal error 107: too many error messages on one line
Line 1007:
pawn Код:
if((!strvalEx(result)%1000))
Any help would be appericated
Re: MySQL Query -
Hiddos - 05.08.2010
Well firstoff I mentioned this:
pawn Код:
new query[126];
format(query,512,"SELECT `rid` FROM `reports` ORDER BY `id` DESC LIMIT 1;");
1) Query's size is 126. How can you format it up to 512?
2) Why use 'format()' when you're not filling in any variables?
You might try:
pawn Код:
if(!strvalEx(result)%1000)
I don't see a reason for another ()
Re: MySQL Query -
Kar - 05.08.2010
also mysql_real_escape_string to protect from getting injectedo.o
or w/e
am I correct? I'm Just Learning Mysql
Re: MySQL Query -
Agent Smith - 05.08.2010
I've changed the query size now.
I'm not that experinced at using MySQL so I looked around at MySQL scripts and saw thats how the do most of their querys.
I've also tried that idea but it came up with the same errors.
Re: MySQL Query -
dice7 - 05.08.2010
May I ask what are you even trying to do here, what are you checking and how is that saved in the database ?
pawn Код:
if((!strvalEx(result)%1000))
And you could also show your strvalEx
Re: MySQL Query -
Agent Smith - 05.08.2010
I'm checking the rid = Report ID. If no report exists then the report ID should be 1, if a report does exist it needs to select the next report ID which isn't being used.
I know what's wrong, I didn't add strvalEx into my script :P
Re: MySQL Query -
Vince - 05.08.2010
For your information: 0 mod 1000 is still 0 and -1 mod 1000 is 999
Re: MySQL Query -
jonrb - 05.08.2010
You can't use '!' like this:
if((!strvalEx(result)%1000))
try:
if(!(strvalEx(result)%1000))