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

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

Post by Shendemiar »

My php outputs a table (mainly read from database), but if i add more rows to the database, then the browser (and php.exe) freezes. Then if i reduce amount of shown columns then it allows more rows to be shown.

I have lots of small include files, but the table itself isnt that big. 7 columns, 5 rows and it freezed.

Is it a problem related with my Apache/PHP settings or a Coding related problem?
Last edited by Shendemiar on Sun Feb 22, 2004 8:42 pm, edited 1 time in total.
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

guessing its a coding issue

5 rows is nothing.
Shendemiar
Forum Contributor
Posts: 404
Joined: Thu Jan 08, 2004 8:28 am

Post by Shendemiar »

Now i did the following:

I put the page to load on my browser... it "freezed" and showed nothing. Then i killed the php.exe vie taskmanager, and isntantlly the page appeared completely and correctly to the browser.

The code also works smoothly on phped's debugger.

So any idea even of the directions that i should be looking into with this?
Shendemiar
Forum Contributor
Posts: 404
Joined: Thu Jan 08, 2004 8:28 am

Post by Shendemiar »

I get the resulting query returned from a function, i'm going to change that and see how it effects it.
Shendemiar
Forum Contributor
Posts: 404
Joined: Thu Jan 08, 2004 8:28 am

Post by Shendemiar »

It didnt do enything, its just the same.

Ill put the code here if anyone can spot something obvious.

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&#1111;'delete'])
	    &#123;include "game_elements/diplomacy_read_delete.php";&#125;

##################################################################################
#        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))
	    &#123;
    	mysql_select_db($DB, $yhteys);
	    $haku = mysql_query($mail, $yhteys) or die("Error in query: "$query"");
	    &#125;

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

    $i=0;
    while ($row = mysql_fetch_array($haku, MYSQL_ASSOC))
    &#123;
    	$i++;
        if ($i % 2 == 0)
        	&#123;
        	$A="1";
        	&#125;
        else
         	&#123;
        	$A="2";
        	&#125;

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

         echo "<tr>";
         $read="";
         if ($row&#1111;'isread']==0)
             &#123;
             $read="<img src="includes/images/unread.gif" alt="Unread!">";
             &#125;
         if ($row&#1111;'isread']==2)
             &#123;
             $read="<img src="includes/images/replied.gif" alt="Replied!">";
             &#125;

		##################################################################################
		#        Print cell's

        PrintCell("<div align="center">".$read."</div>","textrow$A","",2);
        PrintCell($row&#1111;'sent'],"textrow$A","",1);
        PrintCell(nations($row&#1111;'from']),"textrow$A","",0);
        PrintCell(nations($row&#1111;'to']),"textrow$A","",0);
        PrintCell($row&#1111;'message'],"textrow$A","",0);
         	$ID=$row&#1111;'id'];
		 	$del=$Link."diplomacy&act=read&delete=$ID";
            $celltext="$del" onClick="_confirm('Delete this message?',''); return false;"><img src="includes/images/delete.png" border="0" alt="Delete"></a>";
       	PrintCell($celltext,"textrow$A","",0);
        PrintCell("<div align="center"><a href="kana"><img src="includes/images/reply.png" border="0" alt="Reply/Forward"></a></div>","textrow$A","",0);

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

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

	mysql_free_result($haku);
	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>";

	$mailreaad=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 »

Next i'll do the cells manually
Shendemiar
Forum Contributor
Posts: 404
Joined: Thu Jan 08, 2004 8:28 am

Post by Shendemiar »

It helped...

I wonder what was wrong? The function "printcell" i used is small and should be harmless...

Well, it was strange: Debugger told no error at all, yet it didnt work outside the debugger but with very small "load"
Shendemiar
Forum Contributor
Posts: 404
Joined: Thu Jan 08, 2004 8:28 am

Post by Shendemiar »

The same problems keeps coming back to me.

All works fine compared to old, but now when i raise the amout of records to ~20 it all strats again.... PHP freezes!
Shendemiar
Forum Contributor
Posts: 404
Joined: Thu Jan 08, 2004 8:28 am

Post by Shendemiar »

PHP Freezes

I have no errors, all is fine with debugger!

But when i raise the load (more output for php to write) it freezes! Browser is just waiting for something... When i kill the php.exe from taskmanager, the page flashes to the browser just fine...
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post by josh »

dude u reply to yourself alot, maybe it is your version of php is incompatible with your os, php should be able to handle many cells/rows
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

Sounds like an infinite loop.. recheck all your code. and use [ php] tags please, not [ code]
Shendemiar
Forum Contributor
Posts: 404
Joined: Thu Jan 08, 2004 8:28 am

Post by Shendemiar »

LiLpunkSkateR wrote:Sounds like an infinite loop.. recheck all your code. and use [ php] tags please, not [ code]
But if i kill the php.exe, the page displays completely and with no errors. If there was an error, wouldn't it affect the outcome?
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

well, an infinite loop isn't really an error, so php wouldn't catch it

it would keep going through the loop, over and over again, until you told it to stop (killing php.exe), then it would spit w/e it's done so far to the browser.
Shendemiar
Forum Contributor
Posts: 404
Joined: Thu Jan 08, 2004 8:28 am

Post by Shendemiar »

LiLpunkSkateR wrote:well, an infinite loop isn't really an error, so php wouldn't catch it

it would keep going through the loop, over and over again, until you told it to stop (killing php.exe), then it would spit w/e it's done so far to the browser.
Ok thanks, i will inspect it carefullu tomorrow...
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Wow 7 posts in a row? Is that a record?

Cough cough Edit Button
Post Reply