["solved", well, evaded] PHP's / Server's memory?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Shendemiar
Forum Contributor
Posts: 404
Joined: Thu Jan 08, 2004 8:28 am

Post by Shendemiar »

Thats what it is now:

Code: Select all

<table width="100%" border="0" height="10"><tr><td>&nbsp;</td></tr></TABLE>
<table width="100%" border="0" cellpadding="4" cellspacing="4" class="border">
<tr><td>
<strong>&nbsp;&nbsp;&nbsp;Read Messages</strong>
</td></tr>
<tr><td class="inner">

<?php
##################################################################################
#        Delete message

	if ($_GET['delete'])
	    {include "game_elements/diplomacy_delete.php";}

##################################################################################
#        Echo Table headers

    echo "<table class="text" width="100%" cellspacing=3 cellpadding=5>";
    echo "<tr>";
    echo "<td nowrap width="1%" class="header">Status</td>";
    echo "<td nowrap width="1%" class="header">Sent</td>";
    echo "<td width="1%" class="header">From</td>";
    echo "<td width="1%" class="header">To</td>";
    echo "<td width="99%" class="header">Message</td>";
    echo "<td width="1%" class="header">&nbsp;</td>";
    echo "<td width="1%" class="header">&nbsp;</td>";
    echo "</tr>";


##################################################################################
#        Make connection & Query messages

    $mail = "Select * from users_mail where userid=$Player and gameid=$GameNumber order by 'isread' asc, 'from' asc";
    $yhteys = mysql_connect($DBC1, $DBC2, $DBC3) or die ("Error on connect:" . mysql_error());
    if(isset($yhteys))
	    {
    	mysql_select_db($DB, $yhteys);
	    $haku = mysql_query($mail, $yhteys) or die("Error in query: "$query"");
	    }

##################################################################################
#        Select row color

    $i=0;
    while ($row = mysql_fetch_array($haku, MYSQL_ASSOC))
    {
    	$i++;
        if ($i % 2 == 0)
        	{
        	$A="1";
        	}
        else
         	{
        	$A="2";
        	}

		##################################################################################
		#        Choose apropriate picture

         echo "<tr>";
         $read="";
         if ($row['isread']==0)
             {
             $read="<img src="includes/images/unread.gif" alt="Unread!">";
             }
         if ($row['isread']==2)
             {
             $read="<img src="includes/images/replied.gif" alt="Replied!">";
             }

		##################################################################################
		#       Print cell's
		#		$Link = "<a href="game.php?player=".$Player."&game=".$GameNumber."&action=";

        echo "<td class="textrow$A"><div align="center">$read</div></td>";
        echo "<td class="textrow$A">{$row['sent']}</td>";
        $temp1=nations($row['from']);
        echo "<td class="textrow$A">$temp1</td>";

        $temp1=nations($row['to']);
        echo "<td class="textrow$A">$temp1</td>";
        echo "<td class="textrow$A">{$row['message']}</td>";

            $id=$row['id'];
		 	$del=$Link."diplomacy&act=read&delete=".$row['id'];
            $del2="game.php?player=$Player&game=$GameNumber&action=diplomacy&act=read&delete=$id";
            $celltxt="$del" onClick="_confirm('Delete this message?','$del2'); return false;"><img src="includes/images/delete.png" border="0" alt="Delete"></a>";
        echo "<td class="textrow$A">$celltxt</td>";

            $id=$row['id'];
            $del=$Link."diplomacy&act=write&forward=$id";
        	$celltext="$del"><img src="includes/images/reply.png" border="0" alt="Reply/Forward"></a>";
        echo "<td class="textrow$A"><div align="center">$celltext</div></td>";

        echo "</tr>";
		##################################################################################
		#        End of     while ($row = mysql_fetch_array($haku, MYSQL_ASSOC))
    }

##################################################################################
#        End stuff

	echo "</td></tr></table></td></tr><tr><td><div align="right">";
	echo "<strong>You have $i of 100 messages </strong>";
    echo "</div></td></tr></table>";

	$mailread=fetch_query("update users_mail set isread=1 where isread=0 and userid=$Player and gameid=$GameNumber");


?>
Shendemiar
Forum Contributor
Posts: 404
Joined: Thu Jan 08, 2004 8:28 am

Post by Shendemiar »

bv
Last edited by Shendemiar on Sun Feb 22, 2004 8:41 pm, edited 1 time in total.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Try putting this back in at the end of your loop

Code: Select all

<?php
mysql_free_result($haku); 
?>
Also, try running this on a different server.... see if it works.
Shendemiar
Forum Contributor
Posts: 404
Joined: Thu Jan 08, 2004 8:28 am

Post by Shendemiar »

Thanks for the tip, i've been wondering what's it for!

I finally got somewhere!

I turned all error reporting on, and was guided to somewhere completely different, and it solved it.

Now i can have as much stuff there as i want to.

Code: Select all

<?php
if ($_SESSION['logged']=="true")
	{
    $screen_width=$_SESSION['screen_width'];
	}
    else
    {
	$screen_width=800;
    }
?>
Changed it to

Code: Select all

<?php
if ( isset($_SESSION['logged']) && $_SESSION['logged'] == true )
	{
	$screen_width = (isset($_SESSION['screen_width'])) ? $_SESSION['screen_width'] : -1 ;
	}
    else
    {
	$screen_width=800;
    }
?>
and suddently it went smooth as hell!
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

change to this

Code: Select all

<?php 

if (isset($_SESSION['logged']) && ($_SESSION['logged'] == true ))

?>
Sorry I wasn't looking very carefully.. it wouldn't make a dif if you changed it to this or not.... both ways will work... mine just is easier to read
Last edited by John Cartwright on Sun Feb 22, 2004 9:03 pm, edited 1 time in total.
Shendemiar
Forum Contributor
Posts: 404
Joined: Thu Jan 08, 2004 8:28 am

Post by Shendemiar »

I allmost dont dare to touch it, but ok...

Why did that affect the other place?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

could you explain this to me

Code: Select all

<?php
$screen_width = (isset($_SESSION['screen_width'])) ? $_SESSION['screen_width'] : -1 ; 
?>
If the Screen width is set and the get the variable 'screen_width' ... but wat is ": -1 "mean?
Shendemiar
Forum Contributor
Posts: 404
Joined: Thu Jan 08, 2004 8:28 am

Post by Shendemiar »

The expression (expr1) ? (expr2) : (expr3) evaluates to expr2 if expr1 evaluates to TRUE, and expr3 if expr1 evaluates to FALSE.
Post Reply