I'm having the same issue. Says connection successful, but says dead connection when I try to do anything.
Here's the pawn code for the mysql
Code:
public OnPlayerConnect(playerid)
{
new DBHandle = mysql_connect("127.0.0.1","root","samp","changeme");
new pname[24], checkPlayerName[110], result[500], welcome[50];
GetPlayerName(playerid, pname, 24);
mysql_format(DBHandle, checkPlayerName, "SELECT * FROM 'playerdata' WHERE 'user' = '%s'", pname);
mysql_reconnect(DBHandle);
mysql_function_query(DBHandle, checkPlayerName, false, "", "");
mysql_store_result();
new rows = mysql_num_rows();
if(rows == 0)
{
SendClientMessage(playerid, -1, "You don't exist!!");
}
else if(rows == 1)
{
format(welcome,sizeof(welcome), "Welcome back, %s", pname);
SendClientMessage(playerid, -1, welcome);
SendClientMessage(playerid, -1, "lololol");
}
else
{
SendClientMessage(playerid, -1, "this is a fallback");
}
return 1;
}
Here's the mysql.log
Code:
[10:42:27] >> mysql_connect(127.0.0.1, root, samp, ******) on port 3306
[10:42:27] CMySQLHandler::CMySQLHandler() - constructor called.
[10:42:27] CMySQLHandler::CMySQLHandler() - Connecting to "127.0.0.1" | DB: "samp" | Username: "root"
[10:42:27] CMySQLHandler::Connect() - Connection was successful.
[10:42:27] CMySQLHandler::Connect() - Auto-Reconnect has been enabled.
[10:42:50] >> mysql_connect(127.0.0.1, root, samp, ******) on port 3306
[10:42:50] CMySQLHandler::Connect() - Connection was successful.
[10:42:50] CMySQLHandler::Connect() - Auto-Reconnect has been enabled.
[10:42:50] >> mysql_format( Connection handle: 1 )
[10:42:50] >> mysql_reconnect( Connection handle: 1 )
[10:42:50] CMySQLHandler::Disconnect() - Connection was closed.
[10:42:50] CMySQLHandler::Connect() - Connection was successful.
[10:42:50] CMySQLHandler::Connect() - Auto-Reconnect has been enabled.
[10:42:50] >> mysql_query_callback( Connection handle: 1 )
[10:42:50] >> mysql_store_result( Connection handle: 1 )
[10:42:50] CMySQLHandler::StoreResult() - No data to store.
[10:42:50] Passing query SELECT * FROM 'playerdata' WHERE 'user' = 'person' |
[10:42:50] >> mysql_num_rows( Connection handle: 1 )
[10:42:50] CMySQLHandler::ProcessQueryThread() - Error will be triggered to OnQueryError()
[10:42:50] CMySQLHandler::NumRows() - You cannot call this function now. (Reason: Dead Connection)
I don't understand why this is happening, is it a problem with my code? I don't think it's a permissions issue as I'm logging in as root for mysql.
I know it's not wrong login credentials becuase I tried the wrong info and it said that access was denied...