2DaysAway Posted January 13, 2008 Share Posted January 13, 2008 I want a message bar to appear if a player has been attacked or sent a message. When I load the script, the page is blank. I think it's my echo's but I've tried several ways and all same result. Look at it and let me know if you see any code problems or know a better way to write it. <?$get = mysql_query("SELECT round FROM $tab[set] WHERE starts<$time and ends>$time ORDER BY starts ASC;"); while ($game = mysql_fetch_array($get)){ if(fetch("SELECT pimp FROM $tab[pimp] WHERE id='$id' AND rid='$game[round]';")){ $jo3 = "SELECT * from pimps where id='$id' AND rid='$game[round]'"; $jo4 = mysql_query($jo3); $jo5 = mysql_fetch_array($jo4) or die ("Cannot Recieve Message"); if($jo5["messages"] >= 1) { echo = "<table border='0' align='center' cellpadding='0' cellspacing='0'><tr><td>"; echo = "<div class='msg'><div align='center'>"; echo = "<a href='inbox.php?rid=$game[round]'>You Have Mail!</a>"; echo = "</div></div>"; echo = "</td></tr></table>"; } if($jo5["attacks"] >= 1) { echo = "<table border='0' align='center' cellpadding='0' cellspacing='0'><tr><td>"; echo = "<div class='attacked'><div align='center'>"; echo ="<a href='inbox.php?inbox=1&rid=$game[round]'>You've Been Attacked!</a>"; echo = "</div></div>"; echo = "</td></tr></table>"; } }?> Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted January 13, 2008 Share Posted January 13, 2008 We can't help you if you don't tell us what it is, and what isn't working about it. Quote Link to comment Share on other sites More sharing options...
revraz Posted January 13, 2008 Share Posted January 13, 2008 http://www.phpfreaks.com/forums/index.php/topic,6264.0.html Also, use <?php instead of <? Quote Link to comment Share on other sites More sharing options...
2DaysAway Posted January 13, 2008 Author Share Posted January 13, 2008 I want a bar to pop up when a player either has a message or been attacked. It maybe the way I'm requesting it. As long as you guys think that it's written correctly. I'll know what direction to look at. Quote Link to comment Share on other sites More sharing options...
2DaysAway Posted January 13, 2008 Author Share Posted January 13, 2008 yea I tried it with the <?php but same result Quote Link to comment Share on other sites More sharing options...
trq Posted January 13, 2008 Share Posted January 13, 2008 I'm not sure exactly what your doing here.... echo = "<table border='0' align='center' cellpadding='0' cellspacing='0'><tr><td>"; but echo is a language construct, you don't assign values to it, you parse it an argument. eg; echo "<table border='0' align='center' cellpadding='0' cellspacing='0'><tr><td>"; Quote Link to comment Share on other sites More sharing options...
2DaysAway Posted January 13, 2008 Author Share Posted January 13, 2008 ok, so I changed the echos and added a query warning. Still just getting a blank screen. So because of the blank screen, would my error lie in the echos? Or still somewhere in the query? <?php $query = "SELECT round FROM `{$tab[set]}` WHERE `round`='$rid'"; $get = mysql_query($query); if (!$get) { $message = 'Invalid query: ' . mysql_error() . "\n"; $message .= 'Whole query: ' . $query; die($message); } while ($game = mysql_fetch_array($get)){ if(fetch("SELECT pimp FROM `{$tab[pimp]}` WHERE `id`='$id' AND `rid`='$game[round]';")){ $jo3 = "SELECT * FROM pimps WHERE `id`='$id' AND `rid`='$game[round]'"; $jo4 = mysql_query($jo3); $jo5 = mysql_fetch_array($jo4) or die ("Cannot Recieve Message"); if($jo5["messages"] >= 1) { echo "<table border='0' align='center' cellpadding='0' cellspacing='0'><tr><td>"; echo "<div class=\"msg\"><div align=\"center\">"; echo "<a href='inbox.php?rid=$game[round]'>You Have Mail!</a>"; echo "</div></div>"; echo "</td></tr></table>"; } if($jo5["attacks"] >= 1) { echo "<table border='0' align='center' cellpadding='0' cellspacing='0'><tr><td>"; echo "<div class=\"attacked\"><div align=\"center\">"; echo "<a href='inbox.php?inbox=1&rid=$game[round]'>You've Been Attacked!</a>"; echo "</div></div>"; echo "</td></tr></table>"; } }?> Quote Link to comment Share on other sites More sharing options...
Fyorl Posted January 13, 2008 Share Posted January 13, 2008 If you're getting a blank screen it's because your if statement isn't evaluating to true and therefore none of your echos are being run. I would check what values you're getting out of the database with an echo above your if statements. Quote Link to comment Share on other sites More sharing options...
revraz Posted January 13, 2008 Share Posted January 13, 2008 Blank screen could also mean an error in the code. *revised to make more sense Quote Link to comment Share on other sites More sharing options...
Fyorl Posted January 13, 2008 Share Posted January 13, 2008 @revraz: Not necessarily. That's only the case if his error_reporting is set to report no errors. Quote Link to comment Share on other sites More sharing options...
revraz Posted January 13, 2008 Share Posted January 13, 2008 Just pointing out that there are more reasons that just their IF statment that can cause a blank screen. Quote Link to comment Share on other sites More sharing options...
Fyorl Posted January 13, 2008 Share Posted January 13, 2008 True, sorry about that. Quote Link to comment Share on other sites More sharing options...
2DaysAway Posted January 13, 2008 Author Share Posted January 13, 2008 I ran the script in myphpadmin and I'm getting a sql syntax error in line one, so I'm looking this up now. Quote Link to comment Share on other sites More sharing options...
Fyorl Posted January 13, 2008 Share Posted January 13, 2008 If you have an error in your SQL syntax then why isn't your error catching block giving a warning? I'm pretty sure mysql_query returns false on failure. Perhaps revraz is right and you've got a parse error or something somewhere which isn't being displayed. If you have access to your php.ini file then try setting error_reporting to E_ALL. Quote Link to comment Share on other sites More sharing options...
redarrow Posted January 14, 2008 Share Posted January 14, 2008 // } <<< added <?php $query = "SELECT round FROM `{$tab[set]}` WHERE `round`='$rid'"; $get = mysql_query($query); if (!$get) { $message = 'Invalid query: ' . mysql_error() . "\n"; $message .= 'Whole query: ' . $query; die($message); } while ($game = mysql_fetch_array($get)){ if(fetch("SELECT pimp FROM `{$tab[pimp]}` WHERE `id`='$id' AND `rid`='$game[round]';")){ $jo3 = "SELECT * FROM pimps WHERE `id`='$id' AND `rid`='$game[round]'"; $jo4 = mysql_query($jo3); $jo5 = mysql_fetch_array($jo4) or die ("Cannot Recieve Message"); if($jo5["messages"] >= 1) { echo "<table border='0' align='center' cellpadding='0' cellspacing='0'><tr><td>"; echo "<div class=\"msg\"><div align=\"center\">"; echo "<a href='inbox.php?rid=$game[round]'>You Have Mail!</a>"; echo "</div></div>"; echo "</td></tr></table>"; } if($jo5["attacks"] >= 1) { echo "<table border='0' align='center' cellpadding='0' cellspacing='0'><tr><td>"; echo "<div class=\"attacked\"><div align=\"center\">"; echo "<a href='inbox.php?inbox=1&rid=$game[round]'>You've Been Attacked!</a>"; echo "</div></div>"; echo "</td></tr></table>"; } } } ?> Quote Link to comment 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.