Gniew Posted July 5, 2011 Share Posted July 5, 2011 Why is this code not working? All I'm getting is "1" as an echo, when it should be 45GH20 (since, that's what's in the DB) <? $conn = mysql_connect("localhost","0","0"); $db = mysql_select_db("0"); $x = $_GET['x']; $y = $_GET['y']; ?> <table width="75%" border="0"> <tr> <td><? $worked2 = mysql_query("SELECT * FROM `map` WHERE `x`=(1) AND `y`=(0)"); $result2 = mysql_fetch_object($worked2); echo($result2-Number);?></td> </tr> </table> Quote Link to comment https://forums.phpfreaks.com/topic/241157-sql-query-not-working/ Share on other sites More sharing options...
AyKay47 Posted July 5, 2011 Share Posted July 5, 2011 change you query to mysql_query("SELECT * FROM `map` WHERE `x`=1 AND `y`=0") //remove parenthesis Quote Link to comment https://forums.phpfreaks.com/topic/241157-sql-query-not-working/#findComment-1238705 Share on other sites More sharing options...
mikosiko Posted July 5, 2011 Share Posted July 5, 2011 $result2 = mysql_fetch_object($worked2); echo($result2-Number) typo? ... that should be $result2->Number ... assuming "Number" is a valid field in your table `map` Quote Link to comment https://forums.phpfreaks.com/topic/241157-sql-query-not-working/#findComment-1238708 Share on other sites More sharing options...
xyph Posted July 5, 2011 Share Posted July 5, 2011 If you were reporting all errors, like you should be, it would've thrown a ton of errors pointing to the issue. Quote Link to comment https://forums.phpfreaks.com/topic/241157-sql-query-not-working/#findComment-1238711 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.