mysql expression Error

Started by Cool, Nov 06, 2016, 06:50 AM

Previous topic - Next topic

Cool

hi i got an error expression expected triedd to fix but not working
if ( cmd == "changenick" )
{
if (!text) MessagePlayer("[#4682B4][Syntax][#FFFFFF]/changenick <password> <new-nick>",player );
else if (NumTok(text, " ") < 2) MessagePlayer("[#4682B4][Syntax][#FFFFFF] /changenick <password> <new-nick>",player );
else
{
local query = mysql_query( sqliteDB, "SELECT Password FROM Accounts WHERE Name = '" + player.Name + "' COLLATE NOCASE" );
  if( mysql_num_rows( query, 0 ) == null ) MessagePlayer( " [#4682B4][TIP] [#FFFFFF] You are not registered Register With /register pass.", player );
  else
{
local password = (GetTok( text, " ", 1));
  local q1 = mysql_query( sqliteDB, "SELECT Password FROM Accounts WHERE Name = '" + player.Name + "' COLLATE NOCASE" );
  local result = mysql_fetch_assoc( query );
  if( SHA256( password ) != result[ "Password" ]  ) MessagePlayer( " [#4682B4] [Info] [#FFFFFF]Wrong password.", player );
  else
{
local q, data;
local name = GetTok(text, " ", 2), q = mysql_query( sqliteDB, "SELECT * FROM Accounts WHERE Name = '" + name+ "' COLLATE NOCASE" );
while( data = mysql_fetch_assoc( q ) )
{
if ( mysql_num_rows( q ) !== Null ) MessagePlayer("[#4682B4]"+name+"[#FFFFFF] is already a registered user." ,player );
else
{
mysql_query(sqliteDB,"UPDATE Accounts SET Name='"+name+"' WHERE Name='"+player.Name+"'");
mysql_query(sqliteDB,"UPDATE Accounts SET NameLower='" +name.tolower()+ "' WHERE NameLower='"+player.Name.tolower()+"'");
mysql_query(sqliteDB,"UPDATE Properties SET Owner='"+name+"' WHERE Owner='"+player.Name+"'");
mysql_query(sqliteDB,"UPDATE Cars SET Owner='"+name+"' WHERE Owner='"+player.Name+"'");
mysql_query(sqliteDB,"UPDATE LMS SET Name='" +name.tolower()+ "' WHERE Name='"+player.Name.tolower()+"'");
mysql_query(sqliteDB,"UPDATE Spawnwep SET Nick='"+name+"' WHERE Nick='"+player.Name+"'");
mysql_query(sqliteDB,"UPDATE Spawnloc SET Name='"+name+"' WHERE Name='"+player.Name+"'");
player.Name = name;
MessagePlayer("[#4682B4][Changed][#FFFFFF]You have been Successfully Changed Your Name to"+RED+" "+name+".",player)
}
}
mysql_free_result( q );
}
}
}
}

Kewun

Add one more bracket. Or correct the code formatting.

KAKAN

mysql_num_rows( query, 0 ) == null
Remove that 0. num_rows takes only 1 parameter and returns 0 or 1 I guess.
oh no

Thijn

Quote from: KAKAN on Nov 06, 2016, 11:32 AMmysql_num_rows( query, 0 ) == null
Remove that 0. num_rows takes only 1 parameter and returns 0 or 1 I guess.
Which wont throw that error.

His syntax is wrong, and the error is usually straightforward since it will tell you the line and even column where it happens.

Anik

I guess problem is solved. Cuz I gave him solution for. And yes, mysql_num_rows doesn't return 0 or 1 it returns the number of rows.