AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   PHP problem (MySQL query with GET Variable) (https://forums.alliedmods.net/showthread.php?t=155987)

Schwabba 04-29-2011 08:09

PHP problem (MySQL query with GET Variable)
 
Hi,

i know it's a forum for Pawn problems, but it's known for common knowledge, so i'll try it here.

I made a Plugin with Pawn (and that's the clue why i can post it here! xD) and build a website now where you can view some stats etc, i try to start a toplist from X place to X+50 with GET.

PHP Code:

    if(!$HTTP_GET_VARS[site])
    {
        
$query="SELECT * FROM `furienmoney` ORDER BY `furienmoney`.`ac_total` DESC LIMIT 50";
    }
    else
    {
        
$site $HTTP_GET_VARS[site]; // does'nt work
        
$site2 = (int)$HTTP_GET_VARS[site]; // does'nt work
        
$query="SELECT * FROM `furienmoney` ORDER BY `furienmoney`.`ac_total` DESC LIMIT ' . $site2 . ',50";
    } 

I tried many different ways with ' . $var . ', '$var' etc., nothing worked, i always get:

PHP Code:

Warningmysql_numrows(): supplied argument is not a valid MySQL result resource in /usr/www/users/pingst/achievement/players.php on line 64 

And when i try to use an integer instead of a variable, it works fine. But i have to use the variable.


Hope someone can help, thx.

ProIcons 04-29-2011 10:04

Re: PHP problem (MySQL query with GET Variable)
 
Obviously here is Amxmodx Pawn Helping Forum, but anyway

PHP Code:

    if(!$_GET['site'])
    {
        
$query="SELECT * FROM `furienmoney` ORDER BY `furienmoney`.`ac_total` DESC LIMIT 1, 50;";
    }
    else
    {
        
$site $_GET['site'];
        
$query="SELECT * FROM `furienmoney` ORDER BY `furienmoney`.`ac_total` DESC LIMIT ".$site.", 50;";
    } 


Edit: But i would suggest you to take a look of this: http://www.learnphponline.com/securi...tion-mysql-php , In the topic: "SQL Injection Prevention: The Solution In Preventing SQL Attacks"

Schwabba 04-29-2011 11:35

Re: PHP problem (MySQL query with GET Variable)
 
Omg, thank you!


All times are GMT -4. The time now is 04:26.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.