My SQL doesn't create a user
#1

Database connect succesful, but it doesn't create a user.

Why not?

Thanks,,

Код:
#include <a_samp>
#include <a_mysql>

#define SQL_HOST "localhost"
#define SQL_USER "USamp"
#define SQL_PASS "PSamp"
#define SQL_DB "MLSamp"

main()
{
}


public OnGameModeInit()
{
	SetGameModeText("Blank Script");
    if(!mysql_connect(SQL_HOST, SQL_USER, SQL_DB, SQL_PASS))
    {
        print("SQL connection attempt 1 FAILED!");
        if(!mysql_connect(SQL_HOST, SQL_USER, SQL_DB, SQL_PASS))
        {
            print("SQL connection attempt 2 FAILED!");
            if(!mysql_connect(SQL_HOST, SQL_USER, SQL_DB, SQL_PASS))
            {
                print("SQL connection attempt 3 FAILED!");
                return 1;
            }
        }
    }else{
        print("SQL connection succes!");
		new PlayerName[50], password[50];
        new Query[200];
		format(PlayerName, 50, "Harry");
		format(password, 50, "MijnPassword");

        new escpname[50], escpass[50];
		mysql_real_escape_string(PlayerName, escpass);
        mysql_real_escape_string(password, escpname);
    	format(Query, sizeof(Query), "INSERT INTO `users` (`username`, `password`) VALUES ('%s', '%s')", escpname, escpass);
		mysql_query(Query);
		mysql_free_result();
		mysql_error();
	}
	
	return 1;
}

public OnGameModeExit()
{
	return 1;
}
Reply
#2

difficult question? :P
Reply
#3

MySQL logs? MySQL logs file should be in your sa-mp server's directory
Reply
#4

Ah, now I have enabled de log/debug. And now I get an error in de mysql log.

Quote:

[13:35:23] >> mysql_connect( )

[13:35:23] CMySQLHandler::CMySQLHandler() - constructor called.

[13:35:23] CMySQLHandler::CMySQLHandler() - Connecting to "tom-roelofs.nl" | DB: "MLSamp" | Username: "USamp" ...

[13:35:23] CMySQLHandler::Connect() - Host 'here my ip.ip.telfort.nl' is not allowed to connect to this MySQL server (Error ID: 1130)

[13:35:23] >> mysql_real_escape_string( Connection handle: 1 )

Reply
#5

If I use WAMP, it work correctly. But I don't want to use a local computer DB
Reply
#6

I guess you are trying to use a MySQL DB from your webhosting plan; login to your control panel of it (cPanel?) and you somewhere need to add your IP as an extern allowed connection.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)