zelig Posted April 21, 2012 Share Posted April 21, 2012 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 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) Quote Link to comment https://forums.phpfreaks.com/topic/261370-dont-know-where-this-echo-is-coming-from/ Share on other sites More sharing options...
QuickOldCar Posted April 21, 2012 Share Posted April 21, 2012 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 />"; } Quote Link to comment https://forums.phpfreaks.com/topic/261370-dont-know-where-this-echo-is-coming-from/#findComment-1339325 Share on other sites More sharing options...
zelig Posted April 21, 2012 Author Share Posted April 21, 2012 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 />"; } Quote Link to comment https://forums.phpfreaks.com/topic/261370-dont-know-where-this-echo-is-coming-from/#findComment-1339326 Share on other sites More sharing options...
QuickOldCar Posted April 21, 2012 Share Posted April 21, 2012 Place this towards top of your script error_reporting(E_ALL); ini_set("display_errors", 1); Quote Link to comment https://forums.phpfreaks.com/topic/261370-dont-know-where-this-echo-is-coming-from/#findComment-1339330 Share on other sites More sharing options...
litebearer Posted April 21, 2012 Share Posted April 21, 2012 It helps when debugging to place your queries in a string. try... $query = "SELECT * FROM `shop` WHERE `x`='".$x["x"]."' AND `y`='".$x["y"]."' AND `z`='".$x["z"]."' AND `plane`='".$x["plane"]."'"; echo $query; Quote Link to comment https://forums.phpfreaks.com/topic/261370-dont-know-where-this-echo-is-coming-from/#findComment-1339331 Share on other sites More sharing options...
zelig Posted April 21, 2012 Author Share Posted April 21, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/261370-dont-know-where-this-echo-is-coming-from/#findComment-1339333 Share on other sites More sharing options...
litebearer Posted April 21, 2012 Share Posted April 21, 2012 post your code when using the echo $query Quote Link to comment https://forums.phpfreaks.com/topic/261370-dont-know-where-this-echo-is-coming-from/#findComment-1339334 Share on other sites More sharing options...
zelig Posted April 21, 2012 Author Share Posted April 21, 2012 So, why is it placing my username id# into those spots instead of getting the information from the shop table which should be: x = 1 y = 0 z = admin plane = batai Quote Link to comment https://forums.phpfreaks.com/topic/261370-dont-know-where-this-echo-is-coming-from/#findComment-1339335 Share on other sites More sharing options...
litebearer Posted April 21, 2012 Share Posted April 21, 2012 try.. print_r($x); Quote Link to comment https://forums.phpfreaks.com/topic/261370-dont-know-where-this-echo-is-coming-from/#findComment-1339336 Share on other sites More sharing options...
zelig Posted April 21, 2012 Author Share Posted April 21, 2012 Prints my username id#: 9 Quote Link to comment https://forums.phpfreaks.com/topic/261370-dont-know-where-this-echo-is-coming-from/#findComment-1339337 Share on other sites More sharing options...
litebearer Posted April 21, 2012 Share Posted April 21, 2012 from your code, it should be an array. where do you set the value of $x[]? Quote Link to comment https://forums.phpfreaks.com/topic/261370-dont-know-where-this-echo-is-coming-from/#findComment-1339339 Share on other sites More sharing options...
zelig Posted April 21, 2012 Author Share Posted April 21, 2012 Up above: $player = check_user($secret_key, $db); $x = $player->id; It's pulling the login information and putting it into the $player variable. (I believe that's how you explain it...) Quote Link to comment https://forums.phpfreaks.com/topic/261370-dont-know-where-this-echo-is-coming-from/#findComment-1339341 Share on other sites More sharing options...
litebearer Posted April 21, 2012 Share Posted April 21, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/261370-dont-know-where-this-echo-is-coming-from/#findComment-1339344 Share on other sites More sharing options...
zelig Posted April 21, 2012 Author Share Posted April 21, 2012 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 />"; } Quote Link to comment https://forums.phpfreaks.com/topic/261370-dont-know-where-this-echo-is-coming-from/#findComment-1339347 Share on other sites More sharing options...
litebearer Posted April 21, 2012 Share Posted April 21, 2012 put single quotes around the variables in your query. Also make it a habit to put your queries in strings, it makes it soooo much easier to debug Quote Link to comment https://forums.phpfreaks.com/topic/261370-dont-know-where-this-echo-is-coming-from/#findComment-1339353 Share on other sites More sharing options...
zelig Posted April 21, 2012 Author Share Posted April 21, 2012 Worked, thanks! Quote Link to comment https://forums.phpfreaks.com/topic/261370-dont-know-where-this-echo-is-coming-from/#findComment-1339354 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.