Page 1 of 1
[solved] getting a value (error)
Posted: Sun Nov 23, 2003 8:16 pm
by d3ad1ysp0rk
Code: Select all
<?PHP
if($usr!=""){
$username="******";
$password="******";
$database="******";
$dbconnect=mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$ranksql = "SELECT `rank` FROM `phpbb_users` WHERE `username` = '$usr' LIMIT 1";
$rank = mysql_result(mysql_query($ranksql), 0,0); //line 9
echo $rank;
}
else{
echo "crap.";
}
?>
i enter the URL (getrank.php?usr=someone) and it gives me this:
Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /home/gamegate/public_html/getrank.php on line 9
Line 9: $rank = mysql_result(mysql_query($ranksql), 0,0);
I have no idea why this is happening.. i copied it almost exactly from my other script (for my other site) which works, and it doesnt work on this one
at first it wouldnt connect, but then i fixed that, and now this is happening..
thanks for any help
Posted: Sun Nov 23, 2003 9:07 pm
by McGruff
Where to you get $usr from - and do you have register globals off now but it was on before?
Posted: Sun Nov 23, 2003 9:14 pm
by d3ad1ysp0rk
right now im testing my script, so i just enter getrank.php?usr=username
and i havent touched register globals..
i dont know if they're on or not (this isnt my host, im making this site for someone else)
Posted: Sun Nov 23, 2003 9:26 pm
by d3ad1ysp0rk
Posted: Sun Nov 23, 2003 10:01 pm
by McGruff
Try rewriting the script a little defining a $query var to pass to mysql_result and change mysql_query to print some error info:
Code: Select all
<?php
$query = mysql_query($ranksql) or die('Error: ' . mysql_errno() . ' - ' . mysql_error() . '<br/>' . $ranksql . '<br />');
$rank = mysql_result($query, 0,0);
?>
Posted: Sun Nov 23, 2003 10:52 pm
by d3ad1ysp0rk
wow i feel so dumb.. my varname in the DB was 'siterank', NOT 'rank' .. lol
thanks for your help