Web Hosting Talk







View Full Version : Need some help please..


joshprogrammer
01-04-2009, 11:26 PM
Im trying to figure out how to fix an error im getting with 1 of my php scripts. Its for my RPG game i made. But this has me stumped as i tried alot of ways to fix this error but dosnt want to fix.. heres the code:
<? $title="Attack/Defense Shop"; include("header.php");
$type = strtolower($type);
$shop = shop;
print "
<center>
<br><br>";
$stat = mysql_fetch_array(mysql_query("select * from users where id=".$_GET['uid'].""));
if ($_GET['buy']) {
if (is_numeric($_REQUEST["amount"]) == false) {
print "You must enter a numeric value.";
include("footer.php");
exit;
}
And heres the error im getting:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/pimpin4l/public_html/shop.php on line 8
Any help would be much appreciated. Thanks

zoticaic
01-04-2009, 11:33 PM
var_dump("select * from users where id=".$_GET['uid']."");
You see anything odd?
var_dump(mysql_query("select * from users where id=".$_GET['uid'].""));
Anything yet?
You should be able to find the fault from there. HTH

joshprogrammer
01-04-2009, 11:36 PM
whats the var_dump for? thats not in the code.

zoticaic
01-04-2009, 11:37 PM
whats the var_dump for? thats not in the code.
http://www.php.net/manual/en/function.var-dump.php
Enjoy! :agree:

joshprogrammer
01-04-2009, 11:40 PM
string(29) "select * from users where id=" i get this when i use the var_dump

zoticaic
01-04-2009, 11:48 PM
There's your problem, you're not getting a value for $_GET['uid']

joshprogrammer
01-04-2009, 11:50 PM
i see that but ive tried several things and still nothing. Thats the problem im haveing...

foobic
01-05-2009, 12:39 AM
And you're accessing this page via a link like: http://example.com/shop.php?uid=42&buy=1&amount=2 ? Or are you perhaps POSTing the data from a form?
Seriously, before this goes live, learn about MySQL injection (http://en.wikipedia.org/wiki/SQL_injection) - your code is very vulnerable.

joshprogrammer
01-05-2009, 12:55 AM
never mind i figured it out. Thanks for the help guys :)