Raised This Month: $ Target: $400
 0% 

PHP problem (MySQL query with GET Variable)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Schwabba
Senior Member
Join Date: Apr 2008
Old 04-29-2011 , 08:09   PHP problem (MySQL query with GET Variable)
Reply With Quote #1

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.
Schwabba is offline
ProIcons
Senior Member
Join Date: Jan 2009
Location: Greece - Salonica
Old 04-29-2011 , 10:04   Re: PHP problem (MySQL query with GET Variable)
Reply With Quote #2

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"
__________________
function rb return $regsubex($$1-,/(.)/g,$+($chr(2) $+ $chr(3),$r(2,15),$chr(2),\1))

Last edited by ProIcons; 04-29-2011 at 10:12.
ProIcons is offline
Schwabba
Senior Member
Join Date: Apr 2008
Old 04-29-2011 , 11:35   Re: PHP problem (MySQL query with GET Variable)
Reply With Quote #3

Omg, thank you!
Schwabba is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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