SA-MP Forums Archive
Problem MYSQL. - 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: Problem MYSQL. (/showthread.php?tid=601345)



Problem MYSQL. - Morpheine - 20.02.2016

Hi what that errors means?

PHP код:
[12:52:40] [ERROR"mysql_format" invalid connection handle (ID 1)
[
12:52:40] [ERROR"mysql_tquery" invalid connection handle (ID 1
PHP код:
                    mysql_format(SQL, var, sizeof(var), "UPDATE `users` SET `Money`='%d' WHERE `name`='%s'",GetPlayerCash(playerid), playerName);
                    
mysql_tquery(SQL, var, """"); 
I use MYSQL r39-4.


Re: Problem MYSQL. - AmigaBlizzard - 20.02.2016

Did you use "mysql_connect" before using any mysql functions?

Just using
PHP код:
#define SQL 1 
This wouldn't work, you need an active connection first.

PHP код:
// Define your MySQL connection info here
#define MYSQL_HOST                        "127.0.0.1"
#define MYSQL_USER                        "UserName"
#define MYSQL_PASSWORD                    "Password"
#define MYSQL_DATABASE                    "Database"
new SQL// Will hold the connectionhandle to the database
public OnGameModeInit()
{
    
// Connect to the MySQL database and store the connection-handle
    
SQL mysql_connect(MYSQL_HOSTMYSQL_USERMYSQL_DATABASEMYSQL_PASSWORD);
    return 
1;

Like this.


Re: Problem MYSQL. - Morpheine - 20.02.2016

I had this SQL definition:
PHP код:
new SQL = -1
Yes i use mysql_connect, #define MYSQL_HOST and others, but i need to use #define SQL 1?


Re: Problem MYSQL. - AmigaBlizzard - 20.02.2016

No, I'm just saying that defining the connectionhandle manually is not the proper way.
You would be giving your mysql function a fake connection id, while it hasn't been created and therefore, cannot be executed.

It should be done as shown in my last example.

Are you sure your connection is active?
Trying to connect and having a fail would also explain the errors you get.


Re: Problem MYSQL. - Morpheine - 21.02.2016

Solved, i replaced new SQL -1 with new SQL