Jump to content

Don't know where this echo is coming from...


zelig

Recommended Posts

Okay, so, I'm trying to pull the info from my `shop` table where the `users` table matches at x, y, z, and plane.

 

Instead, I'm getting this:

 

Resource id #22    :confused:

 

Where is this coming from? I only have 1 row in my shop table, and it has:

id = 7

name = admin shop

x = 1

y = 0

z = admin

plane = batai

 

I'm standing in the shop right now (as my character, so my users table has the exact same x, y, z, plane)...

 

Any help would be appreciated!

 

$q1 = mysql_query("SELECT * FROM `shop` WHERE `x`='".$x["x"]."' AND `y`='".$x["y"]."' AND `z`='".$x["z"]."' AND `plane`='".$x["plane"]."'")  or die("qry failed: ".mysql_error());

 

Variables:

$x = $x = $player->username; (so it's pulling my username, which it is doing correctly ==> i echoed out $x and it came up with my username)

You are missing additional mysql functions for displaying the data.

 

$q1 = mysql_query("SELECT * FROM `shop` WHERE `x`='".$x["x"]."' AND `y`='".$x["y"]."' AND `z`='".$x["z"]."' AND `plane`='".$x["plane"]."'")  or die("qry failed: ".mysql_error());

while($row = mysql_fetch_array($q1)) {
    // echo out the contents of each row

    echo $row['id']."<br />";
    echo $row['name']."<br />";
    echo $row['x']."<br />";
    echo $row['y']."<br />";
    echo $row['z']."<br />";
    echo $row['plane']."<br />";
} 

Hmm...

 

This just brings up a white screen.

 

$q1 = mysql_query("SELECT * FROM `shop` WHERE `x`='".$x["x"]."' AND `y`='".$x["y"]."' AND `z`='".$x["z"]."' AND `plane`='".$x["plane"]."'")  or die("qry failed: ".mysql_error());
while($row = mysql_fetch_array($q1)) {
// echo out the contents of each row    
echo $row['id']."<br />";    
echo $row['name']."<br />";    
echo $row['x']."<br />";    
echo $row['y']."<br />";    
echo $row['z']."<br />";    
echo $row['plane']."<br />";
} 

Do you see the problem? In your query you are trying to use an array named $x[]; yet you do not have said array. Look thru your code and find ALL the variable you are TRYING to use in your query ,w $x['x'], $x['y'] etc THAT is what should lead you to the solution to your issue

Found the problem. Fixed it.

 

Now, I get this error: qry failed: Unknown column 'admin' in 'where clause'

 

The coordinates I'm are are:

x = 1

y = 0

z = admin

plane = batai

 

It doesn't like z for some reason...

 

Here's my current code:

error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE); 
define("PAGENAME", "Shops");
$player = check_user($secret_key, $db);
$x = $player->x;
$y1 = $player->y;
$z = $player->z;
$plane = $player->plane;
if($_SESSION['234asdfas']){$y = $_SESSION['234asdfas'];}else{echo 'Error: You do not have a session variable set'; exit;}

$query = mysql_query("SELECT * FROM `shop` WHERE `x`=$x AND `y`=$y1 AND `z`=$z AND `plane`=$plane") or die("qry failed: ".mysql_error());
while($row = mysql_fetch_array($query)) {
// echo out the contents of each row    
echo $row['id']."<br />";    
echo $row['name']."<br />";  
echo $row['location']."<br />";
echo $row['itemslist']."<br />";  
echo $row['x']."<br />";    
echo $row['y']."<br />";    
echo $row['z']."<br />";    
echo $row['plane']."<br />";
}

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.