Jump to content

Recommended Posts

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

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

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

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.

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.

 

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

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.