SA-MP Forums Archive
My SQL doesn't create a user - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: My SQL doesn't create a user (/showthread.php?tid=218216)



My SQL doesn't create a user - Battleman - 29.01.2011

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;
}



Re: My SQL doesn't create a user - Battleman - 30.01.2011

difficult question? :P


Re: My SQL doesn't create a user - armyoftwo - 30.01.2011

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


Re: My SQL doesn't create a user - Battleman - 30.01.2011

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 )




Re: My SQL doesn't create a user - Battleman - 30.01.2011

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


Re: My SQL doesn't create a user - woot - 30.01.2011

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.