Weird problem
#1

I have this code:
PHP код:
    new
        
string[526]
     ;
    
format(stringsizeof(string), "SELECT `string` FROM `blogs` WHERE `bid` = '%i' LIMIT 5"acc);
    
mysql_query(string);
    
mysql_store_result();
    if(
mysql_num_rows() > 0)
    {
        
format(string,sizeof(string),"{FF6347}BANK STATEMENT:\n\n{B1C8FB}%s\n",string);
        
ShowPlayerDialog(playerid,DIALOG_BANK_STAT,DIALOG_STYLE_MSGBOX,"{24FF0A}Bank - {FFFFFF}Statement",string,"OK","");
        
mysql_free_result();
    }
    else return
            
ShowPlayerDialog(playeridDIALOG_BANK_STATDIALOG_STYLE_MSGBOX"{24FF0A}Bank - {FFFFFF}Statement""No record was found on this account""OK"""); 
And when it does have "record" it just shows "SELECT `string` FROM `blogs` WHERE `bid` = 'actual input' LIMIT 5"
It doesn't show that actual string, can you see any problem with my code?
Reply
#2

Quote:
Originally Posted by [IL]HeHu
Посмотреть сообщение
I have this code:
PHP код:
    new
        
string[526]
     ;
    
format(stringsizeof(string), "SELECT `string` FROM `blogs` WHERE `bid` = '%i' LIMIT 5"acc);
    
mysql_query(string);
    
mysql_store_result();
    if(
mysql_num_rows() > 0)
    {
        
format(string,sizeof(string),"{FF6347}BANK STATEMENT:\n\n{B1C8FB}%s\n",string);
        
ShowPlayerDialog(playerid,DIALOG_BANK_STAT,DIALOG_STYLE_MSGBOX,"{24FF0A}Bank - {FFFFFF}Statement",string,"OK","");
        
mysql_free_result();
    }
    else return
            
ShowPlayerDialog(playeridDIALOG_BANK_STATDIALOG_STYLE_MSGBOX"{24FF0A}Bank - {FFFFFF}Statement""No record was found on this account""OK"""); 
And when it does have "record" it just shows "SELECT `string` FROM `blogs` WHERE `bid` = 'actual input' LIMIT 5"
It doesn't show that actual string, can you see any problem with my code?
can you show as the script of "acc"(what does it do...or what should it do)
Reply
#3

Here is the whole command:
PHP код:
CMD:statement(playeridparams[])
{
    if(!
IsPlayerInRangeOfPoint(playerid,50.0,2315.952880,-1.618174,26.742187))
        return 
SendClientMessage(playerid,C_RED,"You have to be inside the bank");
    if(!
PlayerInfo[playerid][pIDCard])
        return 
SendClientMessage(playerid,C_RED,"You are not registered in San Andreas");
    new
        
acc,
        
pass
     
;
     if(
sscanf(params,"ii",acc,pass))
         return 
SendClientMessage(playerid,C_NICE,"[Usage] {FFFFFF}/statement [account-number] [account-password]");
    if(
acc 1)
        return 
SendClientMessage(playerid,C_NICE,"[Usage] {FFFFFF}/statement [account-number] [account-password]");
    if(!
DoesBankAccountExist(acc))
        return 
SendClientMessage(playerid,C_RED,"Bank account doesn't exist");
    if(!
IsBankPasswordTrue(acc,pass))
        return 
SendClientMessage(playerid,C_RED,"Bank password is wrong");
    new
        
string[526]
     ;
    
format(stringsizeof(string), "SELECT `string` FROM `blogs` WHERE `bid` = '%i' LIMIT 5"acc);
    
mysql_query(string);
    
mysql_store_result();
    if(
mysql_num_rows() > 0)
    {
        
format(string,sizeof(string),"{FF6347}BANK STATEMENT:\n\n{B1C8FB}%s\n",string);
        
ShowPlayerDialog(playerid,DIALOG_BANK_STAT,DIALOG_STYLE_MSGBOX,"{24FF0A}Bank - {FFFFFF}Statement",string,"OK","");
        
mysql_free_result();
    }
    else return
            
ShowPlayerDialog(playeridDIALOG_BANK_STATDIALOG_STYLE_MSGBOX"{24FF0A}Bank - {FFFFFF}Statement""No record was found on this account""OK""");
    return 
1;

Reply
#4

(i think your string is not good)
try this : format(string, sizeof(string), "SELECT `string` FROM `blogs` WHERE `bid` = '%s' LIMIT 5", acc);


Strings Info:
Код:
Format Strings
Placeholder	 Meaning
%b	 Inserts a number at this position in binary radix
%c	 Inserts a single character.
%d	 Inserts an integer (whole) number
%f	 Inserts a floating point number.
%i	 Inserts an integer.
%s	 Inserts a string.
%x	 Inserts a number in hexadecimal notation.
%%	 Inserts the literal '%'
Reply
#5

bid is a numeric variable, not a string.
Reply
#6

Quote:
Originally Posted by [IL]HeHu
Посмотреть сообщение
bid is a numeric variable, not a string.
oh.. ok so change %s to %d
Reply
#7

It's not an %s, it's an %i, which is the exact same thing as %d
Reply
#8

Quote:
Originally Posted by [IL]HeHu
Посмотреть сообщение
Here is the whole command:
PHP код:
CMD:statement(playeridparams[])
{
    if(!
IsPlayerInRangeOfPoint(playerid,50.0,2315.952880,-1.618174,26.742187))
        return 
SendClientMessage(playerid,C_RED,"You have to be inside the bank");
    if(!
PlayerInfo[playerid][pIDCard])
        return 
SendClientMessage(playerid,C_RED,"You are not registered in San Andreas");
    new
        
acc,
        
pass
     
;
     if(
sscanf(params,"ii",acc,pass))
         return 
SendClientMessage(playerid,C_NICE,"[Usage] {FFFFFF}/statement [account-number] [account-password]");
    if(
acc 1)
        return 
SendClientMessage(playerid,C_NICE,"[Usage] {FFFFFF}/statement [account-number] [account-password]");
    if(!
DoesBankAccountExist(acc))
        return 
SendClientMessage(playerid,C_RED,"Bank account doesn't exist");
    if(!
IsBankPasswordTrue(acc,pass))
        return 
SendClientMessage(playerid,C_RED,"Bank password is wrong");
    new
        
string[526]
     ;
    
format(stringsizeof(string), "SELECT `string` FROM `blogs` WHERE `bid` = '%i' LIMIT 5"acc);
    
mysql_query(string);
    
mysql_store_result();
    if(
mysql_num_rows() > 0)
    {
        
format(string,sizeof(string),"{FF6347}BANK STATEMENT:\n\n{B1C8FB}%s\n",string);
        
ShowPlayerDialog(playerid,DIALOG_BANK_STAT,DIALOG_STYLE_MSGBOX,"{24FF0A}Bank - {FFFFFF}Statement",string,"OK","");
        
mysql_free_result();
    }
    else return
            
ShowPlayerDialog(playeridDIALOG_BANK_STATDIALOG_STYLE_MSGBOX"{24FF0A}Bank - {FFFFFF}Statement""No record was found on this account""OK""");
    return 
1;

look:
Код:
%d	 Inserts an integer (whole) number
%i	 Inserts an integer.
that mean:
if you put %i it will show only few numbers
if you will put %d it will show the WHOLE number that the player has typed

____________________________________
try thismybe it will work :\ i dont have a VERY high knowladge at MySQL)
pawn Код:
CMD:statement(playerid, params[])
{
    new
        acc,
        pass;
    new string[526];
    if(!IsPlayerInRangeOfPoint(playerid,50.0,2315.952880,-1.618174,26.742187)) {
        SendClientMessage(playerid,C_RED,"You have to be inside the bank");
    }
    else {
        if(!PlayerInfo[playerid][pIDCard]) {
            SendClientMessage(playerid,C_RED,"You are not registered in San Andreas");
        }
        else {
            if(sscanf(params,"ii",acc,pass)) {
                SendClientMessage(playerid,C_NICE,"[Usage] {FFFFFF}/statement [account-number] [account-password]");
            }
            else {
                if(acc < 1) {
                    SendClientMessage(playerid,C_NICE,"[Usage] {FFFFFF}/statement [account-number] [account-password]");
                }
                else {
                    if(!DoesBankAccountExist(acc)) {
                        SendClientMessage(playerid,C_RED,"Bank account doesn't exist");
                    }
                    else {
                        if(!IsBankPasswordTrue(acc,pass)) {
                            SendClientMessage(playerid,C_RED,"Bank password is wrong");
                        }
                        else {
                            format(string, sizeof(string), "SELECT `string` FROM `blogs` WHERE `bid` = '%i' LIMIT 5", acc);
                            mysql_query(string);
                            mysql_store_result();
                            if(mysql_num_rows() > 0) {
                                format(string,sizeof(string),"{FF6347}BANK STATEMENT:\n\n{B1C8FB}%s\n",string);
                                ShowPlayerDialog(playerid,DIALOG_BANK_STAT,DIALOG_STYLE_MSGBOX,"{24FF0A}Bank - {FFFFFF}Statement",string,"OK","");
                                mysql_free_result();
                            }
                            else {
                                ShowPlayerDialog(playerid, DIALOG_BANK_STAT, DIALOG_STYLE_MSGBOX, "{24FF0A}Bank - {FFFFFF}Statement", "No record was found on this account", "OK", "");
                            }
                        }
                    }
                }
            }
        }
    }
    return 1;
}
Reply
#9

Nah, thanks for trying though.
Reply
#10

Quote:
Originally Posted by [IL]HeHu
Посмотреть сообщение
Nah, thanks for trying though.
NP
anyway i hope that someone will help you fix this
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)