mysql problem
#1

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);
Reply
#2

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.
Reply
#3

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

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.
Reply
#5

worked fine on phpmyadmin
Reply
#6

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

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
Reply
#8

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

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?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)