[+REP] Mysql Issue
#1

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')"

Reply
#2

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

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

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

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
Reply
#6

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');
Reply
#7

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)