MySQL array callback - error 008: must be a constant expression; assumed -
TheDeath - 09.12.2013
Hello guys and sorry for the two questions in less than a hour, but I need to do this today.
So I am trying to send some extra vars to my callback with the mysql_query_array function but I get this error and I can't figure why.
Код:
F:\Dropbox\SAMP Server\gamemodes\cnr.pwn(372) : error 008: must be a constant expression; assumed zero
Here is a piece of my code:
Код:
new password[H_SHA256_LEN];
password = Hash(inputtext);
printf("Player %s(%i) is trying to register with data:", Username(playerid), playerid);
printf("HASHED INPUT: %s", password);
new user[MAX_PLAYER_NAME+1], query[512];
mysql_real_escape_string(Username(playerid), user);
format(query, sizeof(query), "SELECT * FROM `accounts` WHERE `user` = '%s' LIMIT 0,1", user);
mysql_query_array(query, MYSQL_REGISTER_CHECK_NAME_AVAILABILITY, {playerid, password[]}, connection);
I am looking at the documentation and everything seems right to me.
https://sampwiki.blast.hk/wiki/MySQL_Plu...ysqlQueryArray
Re: MySQL array callback - error 008: must be a constant expression; assumed -
Wizzy951 - 09.12.2013
I think that your error is because:
pawn Код:
new password[H_SHA256_LEN];
Instead of setting a lenght for the the "password" variable, you are trying to use a constant ? I think that your way of hashing the password is wrong. I would suggest you to use
Whirlpool plugin, because it's the safest way to hash passwords. I haven't used SHA256, so the only thing I can suggest you is:
pawn Код:
//Change
new password[H_SHA256_LEN];
//to
new password[64];//actually put the length to the SHA's maximum
And hash the password after that.
Edit: if you decide to use Whirlpool instead of your methods, pm me I will help you.
Re: MySQL array callback - error 008: must be a constant expression; assumed -
TheDeath - 09.12.2013
Quote:
Originally Posted by Wizzy951
I think that your error is because:
pawn Код:
new password[H_SHA256_LEN];
Instead of setting a lenght for the the "password" variable, you are trying to use a constant ? I think that your way of hashing the password is wrong. I would suggest you to use Whirlpool plugin, because it's the safest way to hash passwords. I haven't used SHA256, so the only thing I can suggest you is:
pawn Код:
//Change new password[H_SHA256_LEN]; //to new password[64];//actually put the length to the SHA's maximum
And hash the password after that.
Edit: if you decide to use Whirlpool instead of your methods, pm me I will help you.
|
Thanks for the reply, but actually:
Код:
#define H_SHA256_LEN 64
My error is at the last line:
Код:
mysql_query_array(query, MYSQL_REGISTER_CHECK_NAME_AVAILABILITY, {playerid, password[]}, connection);
Re: MySQL array callback - error 008: must be a constant expression; assumed - Patrick - 09.12.2013
Hmmm, I noticed something, I don't really use StrickenKid's MySQL Version, but why do you have this? try removing the { brackets (not sure)
Re: MySQL array callback - error 008: must be a constant expression; assumed -
TheDeath - 09.12.2013
Quote:
Originally Posted by pds2k12
Hmmm, I noticed something, I don't really use StrickenKid's MySQL Version, but why do you have this? try removing the { brackets (not sure)
|
In the documentation's example it says that this callback should be used like this:
Код:
mysql_query_array("SELECT * FROM `accounts` WHERE `username` = 'MyCoolNick' LIMIT 0,1", MYSQL_RESULT_LOGIN,{playerid, someotherid, anotherid}, connection);
and then
Код:
public OnMysqlQueryArray(resultid, extravars[], MySQL:handle)
{
switch (resultid)
{
case MYSQL_RESULT_LOGIN:
{
// process login with:
// extravars[0] = playerid
// extravars[1] = someotherid
// extravars[2] = anotherid
}
}
return 1;
}
Re: MySQL array callback - error 008: must be a constant expression; assumed -
TheDeath - 10.12.2013
Anybody ?