MySQL[]
#1

i have this in MySQL Debug

Код:
[11:52:44] ---------------------------

[11:52:44] MySQL Debugging activated (09/08/13)

[11:52:44] ---------------------------

[11:52:44]  

[11:52:44] >> mysql_connect( )

[11:52:44] CMySQLHandler::CMySQLHandler() - constructor called.

[11:52:44] CMySQLHandler::CMySQLHandler() - Connecting to "localhost" | DB: "database" | Username: "root" ...

[11:52:44] CMySQLHandler::Connect() - Connection was successful.

[11:52:44] CMySQLHandler::Connect() - Auto-Reconnect has been enabled.

[11:53:00] >> mysql_query( Connection handle: 1 )

[11:53:00] CMySQLHandler::Query(SELECT `pName` = 'WazzUps' FROM `users`) - Successfully executed.

[11:53:00] >> mysql_store_result( Connection handle: 1 )

[11:53:00] CMySQLHandler::StoreResult() - Result was stored.

[11:53:00] >> mysql_num_rows( Connection handle: 1 )

[11:53:00] CMySQLHandler::NumRows() - Returned 0 row(s)

[11:53:00] >> mysql_free_result( Connection handle: 1 )

[11:53:00] CMySQLHandler::FreeResult() - Result was successfully free'd.

[11:53:02] >> mysql_real_escape_string( Connection handle: 1 )

[11:53:02] CMySQLHandler::EscapeString(123123); - Escaped 6 characters to 123123.

[11:53:02] >> mysql_query( Connection handle: 1 )

[11:53:02] CMySQLHandler::Query(INSERT INTO `users` (pName,pPass,pAdmin,pCash) VALUES ('WazzUps','123123,'0','0) - An error has occured. (Error ID: 1064, You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '0','0' at line 1)
here is my script

pawn Код:
#include <a_samp>
#include <streamer>
#include <a_mysql>
#include <sscanf2>

#define mysql_host                                              "localhost"
#define mysql_user                                              "root"
#define mysql_password                                          ""
#define mysql_database                                          "database"

#define green                                                   0x00FF15
#define red                                                     0xFF0000
#define cblue                                                   "{00EEFF}"

#define Regdialog 1
#define Logindialog 0

#pragma tabsize 0

main()
{
    printf("Hi");
}

enum PlayerInfo
{
    Username[23],
    Password[24],
    pAdmin,
    pMoney
}
new PInfo[MAX_PLAYERS][PlayerInfo];

public OnGameModeInit()
{
    mysql_debug(1);
    mysql_connect(mysql_host,mysql_user,mysql_database,mysql_password);
    SetGameModeText("Motel RP");
    CreateDynamicObject(14783,2217.31860352,-1143.14697266,1023.42614746,0.00000000,0.00000000,358.00000000); //object(int3int_kbsgarage) (1)
    CreateDynamicObject(14834,2214.42968750,-1155.06799316,1025.02209473,0.00000000,0.00000000,0.00000000); //object(lm_stripplant) (1)
    CreateDynamicObject(977,2243.01464844,-1160.77770996,1029.68249512,0.00000000,0.00000000,101.75000000); //object(newtowerdoor1) (1)
    CreateDynamicObject(977,2239.39501953,-1160.78808594,1029.68249512,0.00000000,0.00000000,101.74987793); //object(newtowerdoor1) (2)
    CreateDynamicObject(977,2239.33544922,-1171.72338867,1029.68249512,0.00000000,0.00000000,101.74987793); //object(newtowerdoor1) (3)
    CreateDynamicObject(977,2226.59301758,-1186.72668457,1030.40075684,0.00000000,0.00000000,191.74987793); //object(newtowerdoor1) (4)
    CreateDynamicObject(977,2210.59814453,-1190.60839844,1030.40075684,0.00000000,0.00000000,191.74438477); //object(newtowerdoor1) (5)
    CreateDynamicObject(977,2195.11621094,-1174.09912109,1030.30810547,0.00000000,0.00000000,101.24438477); //object(newtowerdoor1) (6)
    CreateDynamicObject(977,2195.09887695,-1158.02233887,1030.30810547,0.00000000,0.00000000,101.23901367); //object(newtowerdoor1) (7)
    CreateDynamicObject(977,2191.23999023,-1157.99169922,1030.30810547,0.00000000,0.00000000,101.23901367); //object(newtowerdoor1) (8)
    CreateDynamicObject(1723,2217.68945312,-1155.00512695,1024.79687500,0.00000000,0.00000000,180.00000000); //object(mrk_seating1) (1)
    CreateDynamicObject(1723,2219.15283203,-1152.37744141,1024.79687500,0.00000000,0.00000000,269.99450684); //object(mrk_seating1) (2)
    CreateDynamicObject(1723,2215.73437500,-1152.02197266,1024.79687500,0.00000000,0.00000000,359.98901367); //object(mrk_seating1) (3)
    CreateDynamicObject(2008,2215.69946289,-1144.85717773,1025.42248535,0.00000000,0.00000000,180.00000000); //object(officedesk1) (1)
    CreateDynamicObject(2166,2215.11059570,-1140.28161621,1025.14624023,0.00000000,0.00000000,0.00000000); //object(med_office_desk_2) (1)
    CreateDynamicObject(1670,2216.16308594,-1153.43225098,1025.35156250,0.00000000,0.00000000,0.00000000); //object(propcollecttable) (1)
    CreateDynamicObject(18028,2240.63012695,-1154.72802734,1024.30493164,0.00000000,0.00000000,90.00000000); //object(smllbarinterior) (1)
    CreateDynamicObject(14651,2241.39306641,-1163.84631348,1024.21655273,0.00000000,0.00000000,88.00000000); //object(trukstp05) (1)
    return 1;
}

stock LoginPlayer(playerid,const password[])
{
    new EscapedText[60];
    new Query[200],pName[24];
    GetPlayerName(playerid,pName,24);
    mysql_real_escape_string(password, EscapedText);
    format(Query,sizeof(Query),"SELECT * FROM `users` WHERE `pName` = '%s' AND `pPass` = '%s'",pName,EscapedText);
    mysql_query(Query);
    mysql_store_result();
    if(mysql_num_rows() != 0)
    {
        SendClientMessage(playerid,green,"You have been logged in!");
        LoadStats(playerid);
    }
    else
    {
            SendClientMessage(playerid,red,"Wrong password!");
        Kick(playerid);
    }
    mysql_free_result();
    return 1;
}
stock LoadStats(playerid)
{
    new pName[24],Query[80];
    GetPlayerName(playerid,pName,24);
    format(Query, sizeof(Query), "SELECT `pName` = '%s' FROM `users`", pName);
    mysql_query(Query);
    mysql_store_result();
    mysql_fetch_row_format(Query, "|");
    sscanf(Query,"e<p<|>s[24]s[23]ii>",PInfo[playerid]);
    mysql_free_result();
    GivePlayerMoney(playerid,PInfo[playerid][pMoney]);
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
    return 1;
}

public OnPlayerConnect(playerid)
{
    new pName[24],Query[80],string[128];
    GetPlayerName(playerid,pName,24);
    format(Query,sizeof(Query),"SELECT `pName` = '%s' FROM `users`",pName);
    mysql_query(Query);
    mysql_store_result();
    if(mysql_num_rows() != 0)//if number of rows is different from 0 then continue
    {
        format(string,sizeof(string),"Hey, %s! \nYour account is registered.\nPlease enter the password to log in!",pName);
        ShowPlayerDialog(playerid,0,DIALOG_STYLE_INPUT,"Log in",string,"Login","");
    }
    else
    {
        format(string,sizeof(string),"Hey, %s! \nYour account is not registered. \nPlease register to continue!",pName);
        ShowPlayerDialog(playerid,1,DIALOG_STYLE_INPUT,"Register",string,"Register","");
    }
    mysql_free_result();
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    return 1;
}

public OnPlayerSpawn(playerid)
{
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    return 1;
}

public OnVehicleSpawn(vehicleid)
{
    return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
    return 1;
}

public OnPlayerText(playerid, text[])
{
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mycommand", cmdtext, true, 10) == 0)
    {
        // Do something here
        return 1;
    }
    return 0;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
    return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
    return 1;
}

public OnRconCommand(cmd[])
{
    return 1;
}

public OnPlayerRequestSpawn(playerid)
{
    return 1;
}

public OnObjectMoved(objectid)
{
    return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
    return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
    return 1;
}

public OnVehicleMod(playerid, vehicleid, componentid)
{
    return 1;
}

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
    return 1;
}

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
    return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
    return 1;
}

public OnPlayerExitedMenu(playerid)
{
    return 1;
}

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
    return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
    return 1;
}

public OnPlayerUpdate(playerid)
{
    return 1;
}

public OnPlayerStreamIn(playerid, forplayerid)
{
    return 1;
}

public OnPlayerStreamOut(playerid, forplayerid)
{
    return 1;
}

public OnVehicleStreamIn(vehicleid, forplayerid)
{
    return 1;
}

public OnVehicleStreamOut(vehicleid, forplayerid)
{
    return 1;
}


public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 1)
    {
        if(strlen(inputtext) == 0)
        {
            ShowPlayerDialog(playerid,Regdialog,DIALOG_STYLE_INPUT,"Register - Enter your password","You are about to register a new account! \nPlease choose the password"cblue" for it! \n","Register!","");
        }
        else
        {
            new EscapedText[60],Query[80],pName[MAX_PLAYER_NAME];
            GetPlayerName(playerid,pName,sizeof(pName));
            mysql_real_escape_string(inputtext, EscapedText);
            format(Query,sizeof(Query),"INSERT INTO `users` (pName,pPass,pAdmin,pCash) VALUES ('%s','%s,'%i','%i')",pName,EscapedText,PInfo[playerid][pAdmin],PInfo[playerid][pMoney]);
            mysql_query(Query);
            SendClientMessage(playerid,green,"You have been successfully registered!");
            GivePlayerMoney(playerid,5000);
            SetPlayerScore(playerid,100);
        }
    }
    if(dialogid == Logindialog)
    {
        if(strlen(inputtext) == 0)
        {
            ShowPlayerDialog(playerid,Regdialog,DIALOG_STYLE_INPUT,"Register - Enter your password","You are about to register a new account! \nPlease choose the password for it! \n","Register!","");
        }
        else
        {
            LoginPlayer(playerid,inputtext);
        }
    }
    return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
    return 1;
}
When i'm registered my account it have that Debug and i'm going in game again but it show me the dialog register... Not dialog login... Anyone?
Reply


Messages In This Thread
MySQL[] - by xganyx - 08.09.2013, 04:53
Re: MySQL[] - by Eyce - 08.09.2013, 05:00
Re: MySQL[] - by Misiur - 08.09.2013, 08:59
Re: MySQL[] - by xganyx - 08.09.2013, 09:13
Re: MySQL[] - by Dragonsaurus - 08.09.2013, 09:15
Re: MySQL[] - by playbox12 - 08.09.2013, 09:28
Re: MySQL[] - by Konstantinos - 08.09.2013, 09:46
Re: MySQL[] - by xganyx - 08.09.2013, 09:49
Re: MySQL[] - by Dragonsaurus - 08.09.2013, 09:54
Re: MySQL[] - by Misiur - 08.09.2013, 10:10

Forum Jump:


Users browsing this thread: 4 Guest(s)