G-stylezzz mysql - Cant set up connection? (R7_
#1

Hello, I am come back to samp after about a year and when i use to script, i used G-stylezz mysql plugin..

now though it has been updated massively in the R7 build and only threaded queries are allowed (which are a good thing to be fair!)


But i am having trouble with using it, i understand what the theory behind it is and i understand the flow of data, but its just not working when i put it into practice.

Here is my script i am practicing with (after following the tutorial on the new R7 build):

pawn Code:
public OnGameModeInit()
{
    dbhandle = mysql_connect("localhost", "root", "samp", "");
   
    mysql_function_query(dbhandle, "SELECT * FROM accounts where Username='Darren'", true, "OnQueryFinished", "");

    if(mysql_ping(dbhandle) == 1) print("yes");
    else print("no");
    return 1;
}

public OnQueryFinished()
{
    new rows, fields;
    cache_get_data(rows, fields);
    if(!rows)
    {
        print(!"Darren is not a registered account on this server!");
    }
    else
    {
        printf("Darren is registered (1 row with %d fields)", fields);
    }
    return 1;
}
Although it is saying "no" in the console with the mysql_ping and the ONQueryFinished function doesnt even get called, i tested it by putting a print(); statement at the very start of the callback, but nothing happens..

and now i am doubting whether it is even connecting to the database properly...

I have already tested the connection with PHP and it works perfectly in that..

so any ideas on what im doing wrong?
Reply
#2

bump
Reply
#3

try to put the
pawn Code:
if(mysql_ping(dbhandle) == 1) print("yes");
    else print("no");
before the query you made..
Reply
#4

Tried it and it still says "no" on the console.

Here is my full script:

http://pastebin.com/r6PPm3eQ
Reply
#5

try replace
pawn Code:
if(mysql_ping(dbhandle) == 1) print("yes");
        else print("no");
to
pawn Code:
if(mysql_ping(dbhandle) != -1) { print("YES!"); }
else { print("NO!"); }
I know it's the same.
Reply
#6

Comes up with "NO!" again, its defiantly not connecting to the SQL server. Just cant work out why, the same connection information works perfectly in PHP

oo, just had a thought.. Maybe my sql server is blocking samp? Ill look into that while im waiting for a reply.
Reply
#7

Enable debug by putting
pawn Code:
mysql_debug();
in OnGameModeInit

It will create a log file, check what it says
Reply
#8

Ah okay,

In the log the first thing i noticed was it didnt recoognise the database name. Thats because i re-installed xampp to make sure it was a fresh copy and i forgot to remake my database and tables..

I have now done that and the error now says:

Code:
[23:46:47] CMySQLHandler::Connect() - Can't connect to MySQL server on 'localhost' (10013) (Error ID: 2003)
I lookde on ****** and it says:

Code:
If the MySQL server is running on Windows, you can connect using TCP/IP. If the server is started with the --enable-named-pipe option, you can also connect with named pipes if you run the client on the host where the server is running. The name of the named pipe is MySQL by default. If you do not give a host name when connecting to mysqld, a MySQL client first tries to connect to the named pipe. If that does not work, it connects to the TCP/IP port. You can force the use of named pipes on Windows by using . as the host name.

...

The error (2003) Can't connect to MySQL server on 'server' (10061) indicates that the network connection has been refused. You should check that there is a MySQL server running, that it has network connections enabled, and that the network port you specified is the one configured on the server.

REF:http://dev.mysql.com/doc/refman/5.5/en/can-not-connect-to-server.html
any ideas?

EDIT:

I have tried enableing network connections and the network ports on mysql but cant work out how to do it, anyone know how to do this?
Reply
#9

Quote:
Originally Posted by DarrenReeder
View Post
Ah okay,

In the log the first thing i noticed was it didnt recoognise the database name. Thats because i re-installed xampp to make sure it was a fresh copy and i forgot to remake my database and tables..

I have now done that and the error now says:

Code:
[23:46:47] CMySQLHandler::Connect() - Can't connect to MySQL server on 'localhost' (10013) (Error ID: 2003)
I lookde on ****** and it says:

Code:
If the MySQL server is running on Windows, you can connect using TCP/IP. If the server is started with the --enable-named-pipe option, you can also connect with named pipes if you run the client on the host where the server is running. The name of the named pipe is MySQL by default. If you do not give a host name when connecting to mysqld, a MySQL client first tries to connect to the named pipe. If that does not work, it connects to the TCP/IP port. You can force the use of named pipes on Windows by using . as the host name.

...

The error (2003) Can't connect to MySQL server on 'server' (10061) indicates that the network connection has been refused. You should check that there is a MySQL server running, that it has network connections enabled, and that the network port you specified is the one configured on the server.

REF:http://dev.mysql.com/doc/refman/5.5/en/can-not-connect-to-server.html
any ideas?

EDIT:

I have tried enableing network connections and the network ports on mysql but cant work out how to do it, anyone know how to do this?
nah, i use Localhost with XAMPP and works.

btw i sent you PM, please read it,
Reply
#10

Do you have libmySQL.dll inside your servers' directory?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)