Page 1 of 3
["solved", well, evaded] PHP's / Server's memory?
Posted: Fri Feb 20, 2004 3:47 pm
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?
Posted: Fri Feb 20, 2004 3:56 pm
by d3ad1ysp0rk
guessing its a coding issue
5 rows is nothing.
Posted: Fri Feb 20, 2004 4:02 pm
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?
Posted: Fri Feb 20, 2004 4:14 pm
by Shendemiar
I get the resulting query returned from a function, i'm going to change that and see how it effects it.
Posted: Fri Feb 20, 2004 4:18 pm
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> </td></tr></TABLE>
<table width="100%" border="0" cellpadding="4" cellspacing="4" class="border">
<tr><td>
<strong> Read Messages</strong>
</td></tr>
<tr><td class="inner">
<?php
##################################################################################
# Delete message
if ($_GETї'delete'])
{include "game_elements/diplomacy_read_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"> </td>";
echo "<td width="1%" class="header"> </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
PrintCell("<div align="center">".$read."</div>","textrow$A","",2);
PrintCell($rowї'sent'],"textrow$A","",1);
PrintCell(nations($rowї'from']),"textrow$A","",0);
PrintCell(nations($rowї'to']),"textrow$A","",0);
PrintCell($rowї'message'],"textrow$A","",0);
$ID=$rowї'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))
}
##################################################################################
# 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");
?>
Posted: Fri Feb 20, 2004 4:24 pm
by Shendemiar
Next i'll do the cells manually
Posted: Fri Feb 20, 2004 4:34 pm
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"
Posted: Fri Feb 20, 2004 8:47 pm
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!
Posted: Fri Feb 20, 2004 8:50 pm
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...
Posted: Fri Feb 20, 2004 9:53 pm
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
Posted: Fri Feb 20, 2004 10:22 pm
by d3ad1ysp0rk
Sounds like an infinite loop.. recheck all your code. and use [ php] tags please, not [ code]
Posted: Sat Feb 21, 2004 8:42 am
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?
Posted: Sat Feb 21, 2004 9:18 am
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.
Posted: Sat Feb 21, 2004 10:17 am
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...
Posted: Sat Feb 21, 2004 4:34 pm
by John Cartwright
Wow 7 posts in a row? Is that a record?
Cough cough Edit Button