SA-MP Forums Archive
mysql problem - 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: mysql problem (/showthread.php?tid=196521)



mysql problem - The_Gangstas - 05.12.2010

the print is correct but... it doesnt input it into the database, it inputs id 0 unbandate 0 and nothing else

pawn Код:
[17:02:04] INSERT INTO Bans (`Banid`,`Name`,`IP`,`UnbanDate`,`Reason`) VALUES (1,'Nerd','192.168.1.10',20,'Auto Speed Hack Ban')
pawn Код:
new bEscape[3][80];
    mysql_real_escape_string(Playername(playerid),bEscape[0]);
    mysql_real_escape_string(ip,bEscape[1]);
    mysql_real_escape_string(reason,bEscape[2]);
    format(GlobalQuery1, sizeof(GlobalQuery1), "INSERT INTO Bans (`Banid`,`Name`,`IP`,`UnbanDate`,`Reason`) VALUES (%d,'%s','%s',%d,'%s')",TempBans[s][Banid],bEscape[0],bEscape[1],TempBans[s][UnbanDate],bEscape[2]);
    printf(GlobalQuery1);
    mysql_query(GlobalQuery1);



Re: mysql problem - Think - 05.12.2010

Try this;

pawn Код:
format(GlobalQuery1, sizeof(GlobalQuery1), "INSERT INTO Bans (`Banid`,`Name`,`IP`,`UnbanDate`,`Reason`) VALUES ('%d','%s','%s','%d','%s')",TempBans[s][Banid],bEscape[0],bEscape[1],TempBans[s][UnbanDate],bEscape[2]);
The (missing?) ' could be a problem, I dont know for sure, but this should do it.


Re: mysql problem - The_Gangstas - 05.12.2010

%d's Don't Use '`s that would cause more problems later on. '`s are for strings


Re: mysql problem - Think - 05.12.2010

Quote:
Originally Posted by The_Gangstas
Посмотреть сообщение
%d's Don't Use '`s that would cause more problems later on. '`s are for strings
Then my script would cause a lot of problems, but its your decision

PS; try PHPMyAdmin, it shows you all the query's you might learn something from it.


Re: mysql problem - The_Gangstas - 05.12.2010

worked fine on phpmyadmin


Re: mysql problem - Think - 05.12.2010

Then enable debug (mysql_debug(1); ) and check the mysql_log.txt


Re: mysql problem - The_Gangstas - 05.12.2010

forgot to open that lol
pawn Код:
[17:23:34] >> mysql_real_escape_string( Connection handle: 1 )

[17:23:34] CMySQLHandler::EscapeString(); - Escaped 0 characters to .

[17:23:34] >> mysql_real_escape_string( Connection handle: 1 )

[17:23:34] CMySQLHandler::EscapeString(); - Escaped 0 characters to .

[17:23:34] >> mysql_real_escape_string( Connection handle: 1 )

[17:23:34] CMySQLHandler::EscapeString(); - Escaped 0 characters to .

[17:23:35] >> mysql_query( Connection handle: 1 )

[17:23:35] CMySQLHandler::Query(UPDATE `Bans` SET `Banid`=0,`Name`='',`IP`='',`UnbanDate`=0,`Reason`='') - Successfully executed.

[17:23:35] >> mysql_close( Connection handle: 1 )

[17:23:35] CMySQLHandler::~CMySQLHandler() - deconstructor called.

[17:23:35] CMySQLHandler::FreeResult() - Result was successfully free'd.
that happens..
why is it saying UPDATE bans? lol


Re: mysql problem - Think - 05.12.2010

Well there ya go, re-compile your script, re-upload and restart your server and check your script for the UPDATE line.


Re: mysql problem - The_Gangstas - 05.12.2010

oh i see the problem

pawn Код:
stock SaveTempBans()
{
    new query[512];
    for(new id; id<Bancount; id++)
    {
        new Escape[3][80];
        mysql_real_escape_string(TempBans[id][BannedName],Escape[0]);
        mysql_real_escape_string(TempBans[id][BannedIP],Escape[1]);
        mysql_real_escape_string(TempBans[id][Reason],Escape[2]);
        format(query, sizeof(query), "UPDATE `Bans` SET `Banid`=%d,`Name`='%s',`IP`='%s',`UnbanDate`=%d,`Reason`='%s'",TempBans[id][Banid],Escape[0],Escape[1],TempBans[id][UnbanDate],Escape[2]);
        mysql_query(query);
    }
}
but that should work fine?