Page 1 of 1

Any idea why this isn't working?

Posted: Sun Jan 13, 2008 2:50 pm
by 2DaysAway
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.

Thanks.

Code: Select all

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

Re: Any idea why this isn't working?

Posted: Sun Jan 13, 2008 3:05 pm
by jimthunderbird
I guess your sql maybe wrong. Did you try to debug it in phpmyadmin?

Also, try putting {} around the array element in your sql string, for example:

Code: Select all

 
$myarr['id'] = 1;
$sql = "select * from mytable where id = '{$myarr['id']}'";
 

Re: Any idea why this isn't working?

Posted: Sun Jan 13, 2008 3:11 pm
by 2DaysAway
I'm looking around phpmyadmin and I don't see where to debug scripts. Do you know where to look more specifically, thanks.

Re: Any idea why this isn't working?

Posted: Sun Jan 13, 2008 3:14 pm
by Zoxive

Code: Select all

<?php
$query = "SELECT round FROM `{$tab[set]}` WHERE `starts`<$time and `ends`>$time ORDER BY `starts` ASC";
$get = mysql_query($query);
if (!$get) {
    $message  = 'Invalid query: ' . mysql_error() . "\n";
    $message .= 'Whole query: ' . $query;
    die($message);
}
?>
Have you done the basics and throw in error checking for every mysql query?

Re: Any idea why this isn't working?

Posted: Sun Jan 13, 2008 3:44 pm
by 2DaysAway
ok, I added the query warning and got rid of the equal signs in the echo. I get no warning and still a blank screen. So would that be because of my echos now or do you still think there is a query problem?

Code: Select all

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

Re: Any idea why this isn't working?

Posted: Sun Jan 13, 2008 3:54 pm
by jimthunderbird
2DaysAway wrote:I'm looking around phpmyadmin and I don't see where to debug scripts. Do you know where to look more specifically, thanks.
try printing out your sql, copy it and run it in phpmyadmin see if there's any result back

Re: Any idea why this isn't working?

Posted: Sun Jan 13, 2008 4:55 pm
by Zoxive
Zoxive wrote:Have you done the basics and throw in error checking for every mysql query?
You are still could be getting a mysql error when you select data from your `pimps` table.

also, put..

Code: Select all

error_reporting(E_ALL);
ini_set('display_errors',true);
At the top of the page.