SA-MP Forums Archive
Mysql retrive problem save and HTTP! - 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)
+--- Thread: Mysql retrive problem save and HTTP! (/showthread.php?tid=392064)



Mysql retrive problem save and HTTP! - doreto - 12.11.2012

I've try to use HTTP to retrive resolve host information about player but for some reason its show error: HTTP_ERROR_BAD_HOST 1
pawn Код:
CMD:check4(playerid,params[])
{
    new result[128];
    //new ip[25] = "2.35.99.186";
    new ip[25] = "84.54.177.51";
    //new ip =GetPlayerIP(playerid);
    format(result,sizeof(result), "linuxthefish.net?ip=%i.",ip);
    HTTP(playerid, HTTP_GET, result, "", "MyHttpResponse");
    return 1;
}
pawn Код:
forward MyHttpResponse(index, response_code, data[]);
public MyHttpResponse(index, response_code, data[])
{
        new buffer[128];
        if(response_code == 200)
        {
            format(buffer, sizeof(buffer), "%s", data);
            SendClientMessage(index, -1, buffer);
        }
        else
        {
            format(buffer, sizeof(buffer), "The request failed! The response code was: %d", response_code); // HTTP_ERROR_BAD_HOST          1
            SendClientMessage(index, -1, buffer);
        }
        return 1;
}
Thanks for everyone who help me solve this issue


Re: Mysql retrive problem save and HTTP! - SuperViper - 12.11.2012

1)

pawn Код:
mysql_fetch_field_row(dt,"reason");     PlayerInfo[playerid][pReason] = strval(dt);
should be

pawn Код:
mysql_fetch_field_row(PlayerInfo[playerid][pReason], "reason");

2)

pawn Код:
stock SetReportlog(playerid,target,report)
{
    new reportlog[256];
    format(reportlog,sizeof(reportlog),"INSERT INTO `reportlog` (`username`,`reported`,`reason`,`IP`) VALUES ('%s','%s','%s','%s')",PlayerName(playerid),PlayerName(target),report,GetPlayerIP(target));
    mysql_query(reportlog);
    mysql_store_result();
    mysql_free_result();
    return 1;
}
should be

pawn Код:
stock SetReportlog(playerid,target,report[])
{
    new reportlog[256];
    format(reportlog,sizeof(reportlog),"INSERT INTO `reportlog` (`username`,`reported`,`reason`,`IP`) VALUES ('%s','%s','%s','%s')",PlayerName(playerid),PlayerName(target),report,GetPlayerIP(target));
    mysql_query(reportlog);
    return 1;
}

3)

Try putting www. before the URL.




/700th post


Re: Mysql retrive problem save and HTTP! - Vince - 12.11.2012

mysql_affected_rows is only to be used after a delete, insert or update statement. Use mysql_num_rows when working with select, show or describe.