SA-MP Forums Archive
[+REP] Mysql Issue - 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: [+REP] Mysql Issue (/showthread.php?tid=599801)



[+REP] Mysql Issue - ahmedraed - 30.01.2016

Hi guys,i've some issues with mysql..i just want to format who's connect in the database but well it doesn't add him

this is the code
Quote:

mysql = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_DATABASE, MYSQL_PASSWORD);
if(mysql_errno() != 0)
{
printf("[MYSQL] The connection has failed.");
}
else
{
printf("[MYSQL] The connection has successful.");
}

Quote:

mysql_format(mysql, query, sizeof(query),"INSERT INTO `users` (`Name`) VALUES ('%s')", pInfo[playerid][Name]);

The Logs:
Quote:

[16:00:02] [MYSQL] The connection has successful.

Quote:

[16:00:02] [DEBUG] mysql_connect - host: "localhost", user: "root", database: "Server", password: "****", port: 3306, autoreconnect: true, pool_size: 2
[16:00:02] [DEBUG] CMySQLHandle::Create - creating new connection..
[16:00:02] [DEBUG] CMySQLHandle::CMySQLHandle - constructor called
[16:00:02] [DEBUG] CMySQLHandle::Create - connection created (id: 1)
[16:00:02] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
[16:00:02] [DEBUG] CMySQLConnection::Connect - connection was successful
[16:00:02] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled
[16:00:02] [DEBUG] mysql_errno - connection: 1
[16:00:02] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
[16:00:02] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
[16:00:02] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
[16:00:02] [DEBUG] CMySQLConnection::Connect - connection was successful
[16:00:02] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled
[16:00:02] [DEBUG] CMySQLConnection::Connect - connection was successful
[16:00:02] [DEBUG] CMySQLConnection::Connect - connection was successful
[16:00:02] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled
[16:00:02] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled
[16:02:07] [DEBUG] mysql_format - connection: 1, len: 128, format: "INSERT INTO `users` (`Name`) VALUES ('%s')"




Re: [+REP] Mysql Issue - Prostilov - 30.01.2016

Is the pInfo[playerid][Name] variable set upon the player connecting?


Re: [+REP] Mysql Issue - perfectboy - 30.01.2016

try getting the players name in a string before the query sometimes these error comes up while using enums with mysql_format


Re: [+REP] Mysql Issue - Sawalha - 30.01.2016

what the guys above me told is correct, but i'm just showing you what they told as a code,
make sure that you have defined 'Name' variable in pInfo enum as string:
pawn Код:
Name[MAX_PLAYER_NAME],
and under OnPlayerConnect:
pawn Код:
GetPlayerName(playerid, pInfo[playerid][Name], MAX_PLAYER_NAME);
- note, add this code before the query codes, not after.


Re: [+REP] Mysql Issue - ahmedraed - 30.01.2016

i already defined the name in pInfo[playerid][Name] even i was using mysql R5 before and it was working fine also i use pInfo[playerid][Name] alot of times in the GM and it works fine


Re: [+REP] Mysql Issue - biker122 - 30.01.2016

To know better, execute the same code directly on your SQL Server.

1. Go to your phpMyAdmin
2. Select the database.
3. Open the table you wish to edit.
4. Click on "SQL"
5. Execute the query by replacing the variables with proper values.
Example: INSERT INTO `users` (`Name`) VALUES ('Your_Name');


Re: [+REP] Mysql Issue - ahmedraed - 30.01.2016

tried not working with the GM but works on phpmyadmin
EDIT: Oh shit my bad....i forgot the mysql_query w/e rep for everyone thanks for your time