Mysql querry problem
#1

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 :/ )
Reply
#2

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

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)