Jump to content

Weird problem with fetch_array... not fetching, everything seems fine.


kernelgpf

Recommended Posts

$riderid=$_GET['riderid'];
$query=mysql_query("select * from riders where ridersid='$riderid'")or die(mysql_error());
$row=mysql_fetch_array($query);

if($_GET['action'] == "levelrider"){
if($row[owner] != "$sid"){
print "You don't own this rider.";
exit;
}


That's my code. Everything seems to be working right. action=levelrider is in the URL, no error is being printed out, $sid is equalling what it should, but $row[owner] doesn't show up. It's the correct column name, isn't a blank value...
Your curly braces aren't balanced:
[code]<?php
$riderid=$_GET['riderid'];
$query=mysql_query("select * from riders where ridersid='$riderid'")or die(mysql_error());
$row=mysql_fetch_assoc($query); // changed to getting an associative array
echo '<pre>'.print_r($row,true).'</pre>';  //debug statement -- see what is being returned

if($_GET['action'] == "levelrider"){
    if($row[owner] != $sid){ // don't need the double quotes here
       print "You don't own this rider.";
       exit;
     }
} // added this end curly brace.
?>[/code]

See my comments in the code.

Ken

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.