SA-MP Forums Archive
Error - Must be assigned to an array - 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)
+--- Thread: Error - Must be assigned to an array (/showthread.php?tid=418127)



Error - Must be assigned to an array - mrtms - 23.02.2013

I have this error that I keep getting and I have no idea why I'm getting it and I have no idea how to fix it.
PHP код:
Line (13643) : error 006: must be assigned to an array 
Here is the code:
PHP код:
COMMAND:referr(playerid, params[])
{
    new 
playername[24], string[100];
    if(!
PlayerInfo[playerid][pReferedBy]) return SendClientMessage(playerid, COLOR_GRAD3, "You have already previously referred somebody.");
    if(
sscanf(params, "s[24]", playername)) return Usage(playerid, "/referr [playername]");
    
//Pull MySQL information from the SQL database
    
format(string, sizeof(string), "SELECT `Name` FROM `users` WHERE `Name`='%s'", playername);
    
mysql_query(string);
    
mysql_store_result();
    if(!
mysql_num_rows()) return SendClientMessage(playerid, COLOR_GRAD3, "The players name you provided is not an existing players name.");
    if(
accountID[playerid] == GetOfflinePlayerInt(playername, "accountid")) return SendClientMessage(playerid, COLOR_GRAD3, "You cannot another one of your characters.");
    if(
PlayerInfo[playerid][pIP] == GetOfflinePlayerInt(playername, "ip")) return SendClientMessage(playerid, COLOR_GRAD3, "You cannot referr somebody with the same IP Address.");
    
mysql_free_result();
    
//Referral system
    
PlayerInfo[playerid][pReferedBy] = playername;
    return 
1;
} 
The error is pointing to this line: PlayerInfo[playerid][pReferedBy] = playername;


Re: Error - Must be assigned to an array - Misiur - 23.02.2013

pawn Код:
PlayerInfo[playerid][pReferedBy] = playername;
//changes into
strcat(PlayerInfo[playerid][pReferedBy], playername);
#protip: use mysql_format and %e argument


Re: Error - Must be assigned to an array - mrtms - 23.02.2013

That fixed that problem. Can you show me the parameters for mysql_format and an example please? Also, what is wrong with using format();?


Re: Error - Must be assigned to an array - Misiur - 23.02.2013

https://sampwiki.blast.hk/wiki/MySQL#mysql_format

Probably I'm a little paranoid here, because user name can contain only specified characters, but using non escaped queries can result in sql injection. You can use normal format, but don't forget to escape queries ( https://sampwiki.blast.hk/wiki/MySQL#mys..._escape_string )


Re: Error - Must be assigned to an array - mrtms - 23.02.2013

strcat(PlayerInfo[playerid][pReferedBy], playername); isn't working properly


Re: Error - Must be assigned to an array - mrtms - 23.02.2013

I fixed the problem. Thanks for the help!