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)

Link to comment
Share on other sites

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 />";
} 

Link to comment
Share on other sites

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 />";
} 

Link to comment
Share on other sites

The echo $query pulls:

 

SELECT * FROM `shop` WHERE `x`='9' AND `y`='9' AND `z`='9' AND `plane`='9'

 

So... it's inserting my user id # into those spots...

 

And I have the error reporting stuff in there. Still, just a blank white screen.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 />";
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.