MySQL Query
#1

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
Reply
#2

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 ()
Reply
#3

also mysql_real_escape_string to protect from getting injectedo.o

or w/e

am I correct? I'm Just Learning Mysql
Reply
#4

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.
Reply
#5

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
Reply
#6

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
Reply
#7

For your information: 0 mod 1000 is still 0 and -1 mod 1000 is 999
Reply
#8

You can't use '!' like this:
if((!strvalEx(result)%1000))
try:
if(!(strvalEx(result)%1000))
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)