• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Server] MYSQL R41-4
#1
Good afternoon, I am using the mysql plugin and I have this problem.



[color=#333333][size=small][font=Tahoma, Verdana, Arial, sans-serif]
Code:
[/font][/size][/color]

[04/28/21 11:14:16] [ERROR] mysql_format: invalid connection handle '0'

[04/28/21 11:14:16] [ERROR] mysql_format: invalid connection handle '0'

[04/28/21 11:14:16] [ERROR] mysql_format: invalid connection handle '0'

[04/28/21 11:14:16] [ERROR] error #1065 while executing query "": Query was empty

[04/28/21 11:14:16] [ERROR] error #1065 while executing query "": Query was empty

[04/28/21 11:14:16] [ERROR] error #1065 while executing query "": Query was empty

[04/28/21 11:14:23] [ERROR] mysql_format: invalid connection handle '0'

[04/28/21 11:14:23] [ERROR] error #1065 while executing query "": Query was empty

[04/28/21 11:14:24] [ERROR] mysql_format: invalid connection handle '0'

[04/28/21 11:14:24] [ERROR] error #1065 while executing query "": Query was empty

[04/28/21 11:16:48] [ERROR] error #1064 while executing query "er Logs:{ffffff} ComandoLog

": You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'er Logs:{ffffff} ComandoLog' at line 1





My server and linux and I'm using another windows vps with xampp to use the database

I've managed to make the connection but I can't add or consult anything in the database



Can someone help me?
  Reply
#2
To see where those errors are coming from you have to put at the top of the OnGamemodeInit callback the function "mysql_log(ALL);" so in logs > mysql > mysql.log you can see what query it was



And i recommend you to see the github code breaker mysql thing in the page of it.
Argentinian SA-MP Programmer. Playing since 2013.

  Reply
#3
I changed to R41-3

[04/28/21 14:36:15] [DEBUG] CConnection::CConnection(this=0xec67c008, host='IP', user='USER', passw='PASS', db='logs_servidor', options=0x97ede98)
[04/28/21 14:36:15] [DEBUG] CConnection::CConnection - new connection = 0x9888af8
[04/28/21 14:36:15] [DEBUG] CThreadedConnection::CThreadedConnection(this=0xec67c008, connection=0xec67c008)
[04/28/21 14:36:15] [DEBUG] CThreadedConnection::WorkerFunc(this=0xec67c008, connection=0xec67c008)
[04/28/21 14:36:15] [INFO] Connection handle with id '1' successfully created.
[04/28/21 14:36:15] [DEBUG] CHandleManager::Create - new handle = 0x97a2758
[04/28/21 14:36:15] [DEBUG] mysql_connect: return value: '1'

[04/28/21 14:42:26] [ERROR] mysql_format: invalid connection handle '0'
[04/28/21 14:42:26] [ERROR] error #1065 while executing query "": Query was empty
[04/28/21 14:42:26] [ERROR] mysql_format: invalid connection handle '0'
[04/28/21 14:42:26] [ERROR] error #1065 while executing query "": Query was empty
[04/28/21 14:42:29] [ERROR] error #1064 while executing query "er Logs:{ffffff} ComandoLog
": You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'er Logs:{ffffff} ComandoLog' at line 1

I am not able to find the error, only that the version of mysql server is different
  Reply
#4
on localhost on the linux vps itself the code works normally?
  Reply
#5
(2021-04-28, 05:47 PM)israel_Oliveira Wrote: I changed to R41-3



[04/28/21 14:36:15] [DEBUG] CConnection::CConnection(this=0xec67c008, host='IP', user='USER', passw='PASS', db='logs_servidor', options=0x97ede98)

[04/28/21 14:36:15] [DEBUG] CConnection::CConnection - new connection = 0x9888af8

[04/28/21 14:36:15] [DEBUG] CThreadedConnection::CThreadedConnection(this=0xec67c008, connection=0xec67c008)

[04/28/21 14:36:15] [DEBUG] CThreadedConnection::WorkerFunc(this=0xec67c008, connection=0xec67c008)

[04/28/21 14:36:15] [INFO] Connection handle with id '1' successfully created.

[04/28/21 14:36:15] [DEBUG] CHandleManager::Create - new handle = 0x97a2758

[04/28/21 14:36:15] [DEBUG] mysql_connect: return value: '1'



[04/28/21 14:42:26] [ERROR] mysql_format: invalid connection handle '0'

[04/28/21 14:42:26] [ERROR] error #1065 while executing query "": Query was empty

[04/28/21 14:42:26] [ERROR] mysql_format: invalid connection handle '0'

[04/28/21 14:42:26] [ERROR] error #1065 while executing query "": Query was empty

[04/28/21 14:42:29] [ERROR] error #1064 while executing query "er Logs:{ffffff} ComandoLog

": You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'er Logs:{ffffff} ComandoLog' at line 1



I am not able to find the error, only that the version of mysql server is different



[04/28/21 14:42:26] [ERROR] mysql_format: invalid connection handle '0'



It says that you are using a wrong connection handle in your MySQL Format.



You are using something like mysql_format(0, query, sizeof(query), "INSERT INTO..." instead of mysql_format(Dtabase, query, sizeof(query), "INSERT INTO..."



And how you define Database?



Well, using it in the mysql_connect at the OnGamemodeInit.



new MySQL: Database; // This is going at the start of the gamemode.



new MySQLOpt: option_id = mysql_init_options(); // This, in GamemodeInit as the two below this one.

mysql_set_option(option_id, AUTO_RECONNECT, true); // We will set that option to automatically reconnect on timeouts.

Database = mysql_connect(IP_SQL, USER_SQL, PASSWORD_SQL, DATABASE_SQL, option_id);
Argentinian SA-MP Programmer. Playing since 2013.

  Reply
#6
Thanks to everyone, I had already solved the problem but I ended up not commenting here, it was a simple syntax error
  Reply
#7
(2021-04-30, 04:59 PM)israel_Oliveira Wrote: Thanks to everyone, I had already solved the problem but I ended up not commenting here, it was a simple syntax error

There was indeed a syntax error in the logs. However:



Quote:[04/28/21 14:36:15] [INFO] Connection handle with id '1' successfully created.

A connection with id 1 was created (as literally stated in the logs). But then there's this log:

Quote:[04/28/21 11:14:16] [ERROR] mysql_format: invalid connection handle '0'

That has nothing to do with a syntax error. When you create a variable without a value, it's initial value will be 0. It is quite possible you used a wrong variable or created a new one (or the value of the variable with the MySQL connection ID was set to 0) for the connection handle:



Code:
//Global variable:

new MySQL:dbHandle;



//In your script initialisation:

dbHandle = mysql_connect(...);



//In the script that says "invalid connection handle '0'"

new MySQL:somethingElse;

mysql_format(somethingElse, ...);

//Correct: mysql_format(dbHandle, ...);
  Reply


Forum Jump: