SA-MP Forums Archive
Mysql querry problem - 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: Mysql querry problem (/showthread.php?tid=600909)



Mysql querry problem - smokks - 14.02.2016

Hi friends, Humm so i have a problem with the argument of a querry. I try to follow Mysql tutorial, but, when i just past what it's said, Pawno say me "argument type mismach 1"

Let's show the code

new string[256];
format(string,sizeof(string),"SELECT `Name` FROM `players` WHERE `Name` = '%s'",PlayerName);
mysql_query(string);



C:\**(62) : error 035: argument type mismatch (argument 1)
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Errors.

Thanks you and sorry for my english (i'm french :/ )


Re: Mysql querry problem - K0P - 14.02.2016

Add the connection handle in mysql_query(); function

Код:
new mysql;

#define    MYSQL_HOST        ""
#define    MYSQL_USER        ""
#define    MYSQL_DATABASE    ""
#define    MYSQL_PASSWORD    ""

public OnGameModeInit()
{
    mysql = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_DATABASE, MYSQL_PASSWORD);
    return 1;
}

        new string[256];
	format(string,sizeof(string),"SELECT `Name` FROM `players` WHERE `Name` = '%s'",PlayerName);
	mysql_query(/*here you need the connection handle*/ mysql ,string);



Re: Mysql querry problem - smokks - 14.02.2016

Humm but what's the connection handle? Because i have hard about this but never get what is it


Re: Mysql querry problem - AmigaBlizzard - 14.02.2016

It's the value returned by "mysql_connect" as shown in the example from "KOP".

PHP код:
mysql mysql_connect(MYSQL_HOSTMYSQL_USERMYSQL_DATABASEMYSQL_PASSWORD); 
"mysql" is your connection handle in this case.
You should include it to all your mysql commands to avoid confusion.