Error - Must be assigned to an array
#1

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 006must be assigned to an array 
Here is the code:
PHP код:
COMMAND:referr(playeridparams[])
{
    new 
playername[24], string[100];
    if(!
PlayerInfo[playerid][pReferedBy]) return SendClientMessage(playeridCOLOR_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(stringsizeof(string), "SELECT `Name` FROM `users` WHERE `Name`='%s'"playername);
    
mysql_query(string);
    
mysql_store_result();
    if(!
mysql_num_rows()) return SendClientMessage(playeridCOLOR_GRAD3"The players name you provided is not an existing players name.");
    if(
accountID[playerid] == GetOfflinePlayerInt(playername"accountid")) return SendClientMessage(playeridCOLOR_GRAD3"You cannot another one of your characters.");
    if(
PlayerInfo[playerid][pIP] == GetOfflinePlayerInt(playername"ip")) return SendClientMessage(playeridCOLOR_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;
Reply
#2

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

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

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

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

I fixed the problem. Thanks for the help!
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)