472,965 Members | 2,136 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,965 software developers and data experts.

function dying right in the middle of a for() loop, while simply doing a bunch of echo statements

Right now, over at www.monkeyclaus.org, the following script is
getting to the 9th run through and dying after the line:

echo "...";
You'll admit that is a strange place to die. I've hit refresh several
times and it keeps happening. When I view page source, the last thing
that shows up is the "...". The date doesn't print, nor does the
closing the div tag.

Can anyone suggest a place I should start to look for the problem? It
doesn't seem possible it is here, though it looks that way.


function mostRecentComments($number=10) {
global $sql, $config;
extract($config);
// 06-17-03 - So the purpose of this function is to allow the
designer to list blurbs from recent comments
// in the margins. The number of comments returned is variable,
depending on the number given as an argument
// to the function. If it is 20 then the most recent 20 comments get
returned. The title or headline of the
// comment gets wrapped in a link so people can go read it, and from
there of course, they can link back to
// the page on which it is posted.
$dbArray = $sql->getAllTypeFromDb("comments");
$dbArray = array_reverse($dbArray);

echo "<div class=\"recentComments\">";
echo "These are the most recent $number comments:<br>";
for ($i=0; $i < $number; $i++) {
$row = $dbArray[$i];
$date = outputDate($row[3], 1);
$commentLink = $pathToIndex."?comment[]=";
$commentLink .= $row[0];
$row[2] = substr($row[2], 0, 80);
$row[2] = strip_tags($row[2]);
echo "<div class=\"recentCommentsEach\"><a
class=\"recentCommentLinks\" href=\"$commentLink\">\n";
echo $row[1];
echo "</a>\n";
echo " - ";
echo $row[2];
echo "... ";
echo "<br>\n";
echo $date;
echo "</div>\n\n";
}
echo "</div>";
echo "this is us after the end";
}
Jul 16 '05 #1
2 2137

On 11-Jul-2003, lk******@geocities.com (lawrence) wrote:
Right now, over at www.monkeyclaus.org, the following script is
getting to the 9th run through and dying after the line:

echo "...";
You'll admit that is a strange place to die. I've hit refresh several
times and it keeps happening. When I view page source, the last thing
that shows up is the "...". The date doesn't print, nor does the
closing the div tag.

Can anyone suggest a place I should start to look for the problem? It
doesn't seem possible it is here, though it looks that way.


function mostRecentComments($number=10) {
global $sql, $config;
extract($config);
// 06-17-03 - So the purpose of this function is to allow the
designer to list blurbs from recent comments
// in the margins. The number of comments returned is variable,
depending on the number given as an argument
// to the function. If it is 20 then the most recent 20 comments get
returned. The title or headline of the
// comment gets wrapped in a link so people can go read it, and from
there of course, they can link back to
// the page on which it is posted.
$dbArray = $sql->getAllTypeFromDb("comments");
$dbArray = array_reverse($dbArray);

echo "<div class=\"recentComments\">";
echo "These are the most recent $number comments:<br>";
for ($i=0; $i < $number; $i++) {
$row = $dbArray[$i];
$date = outputDate($row[3], 1);
$commentLink = $pathToIndex."?comment[]=";
$commentLink .= $row[0];
$row[2] = substr($row[2], 0, 80);
$row[2] = strip_tags($row[2]);
echo "<div class=\"recentCommentsEach\"><a
class=\"recentCommentLinks\" href=\"$commentLink\">\n";
echo $row[1];
echo "</a>\n";
echo " - ";
echo $row[2];
echo "... ";
echo "<br>\n";
echo $date;
echo "</div>\n\n";
}
echo "</div>";
echo "this is us after the end";
}


I assume you are looking at the source from the browser's point of view.
That means that the script may not have died where you think because of
buffering. My guess is that $dbArray has less than $number-1 elements.

--
Tom Thackrey
www.creative-light.com
Jul 16 '05 #2
"Tom Thackrey" <to***@creative-light.com> wrote in message
I assume you are looking at the source from the browser's point of view.
That means that the script may not have died where you think because of
buffering. My guess is that $dbArray has less than $number-1 elements.


Thanks for the tip about buffering. That was a good tip. In fact, such
strange things are happening with buffering that Netscape 7 will
partially render the page, but AOL, using IE I think, gives me a "Page
unavailable" error. Same page.

I added a print_r($dbArray) line to the function below, to test your
idea that there are less that $number-1 elements. Actually, there are
34 elements. (Logging in with phpMyAdmin and running the same query, I
find that 34 is the correct number - exactly what should be expected).
Again, Netscape 7 on a PC is willing to partially render the page. It
stops rendering about 1/3 of the way throught the $dbArray but if you
look at the page source the whole thing is there.

Adding print_r($dbArray) helped more of the page render. Netscape was
willing to render a portion of the top right navigation bar, which is
wasn't willing to do till I added the print_r() line. Needless to say,
it is strange that adding print_r() should help a page render more.

AOL, using IE, still refuses to render the page at all. Here's the
function with the print_r line in it:


function mostRecentComments($number=10) {
global $sql, $config;
extract($config);
// 06-17-03 - So the purpose of this function is to allow the
designer to list blurbs from recent comments
// in the margins. The number of comments returned is variable,
depending on the number given as an argument
// to the function. If it is 20 then the most recent 20 comments get
returned. The title or headline of the
// comment gets wrapped in a link so people can go read it, and from
there of course, they can link back to
// the page on which it is posted.
$dbArray = $sql->getAllTypeFromDb("comments");
$dbArray = array_reverse($dbArray);
print_r($dbArray);
echo "<div class=\"recentComments\">";
echo "These are the most recent $number comments:<br>";
for ($i=0; $i < $number; $i++) {
$row = $dbArray[$i];
$date = outputDate($row[3], 1);
$commentLink = $pathToIndex."?comment[]=";
$commentLink .= $row[0];
$row[2] = substr($row[2], 0, 80);
$row[2] = strip_tags($row[2]);
echo "<div class=\"recentCommentsEach\"><a
class=\"recentCommentLinks\" href=\"$commentLink\">\n";
echo $row[1];
echo "</a>\n";
echo " - ";
echo $row[2];
echo "... ";
echo "<br>\n";
echo $date;
echo "</div>\n\n";
}
echo "</div>";
echo "this is us after the end";
}
Jul 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Chris | last post by:
If I'm thinking right, this should work...can someone help me understand why it's not. //$loop = 1 $test = "num$loop"; //test should now equal "num1" $ttest = $$test; //ttest should now...
9
by: Penn Markham | last post by:
Hello all, I am writing a script where I need to use the system() function to call htpasswd. I can do this just fine on the command line...works great (see attached file, test.php). When my...
12
by: David W. Thorell | last post by:
I am trying to write a basic spell check function, one which has as its parameters two strings arrays, one is an article from a file source which needs to be checked for valid words, in this case...
5
by: Sandra-24 | last post by:
Is there a way in python to add the items of a dictionary to the local function scope? i.e. var_foo = dict. I don't know how many items are in this dictionary, or what they are until runtime. ...
16
by: mdh | last post by:
May I ask the group the following: (Again, alas , from K&R) This is part of a function: while ( ( array1 = array2 ) != '\0' ); /* etc etc */ Is this the order that this is evaluated? ...
32
by: chris.fairles | last post by:
Just want an opinion. I have an algorithm that needs to run as fast as possible, in fact. Its already too slow. I've done as much algorithmic changes as I can to reduce the amount of code, so now...
28
by: Larax | last post by:
Best explanation of my question will be an example, look below at this simple function: function SetEventHandler(element) { // some operations on element element.onclick = function(event) {
2
by: ELINTPimp | last post by:
Hello all, Have a really interesting problem (at least to me) with my upload_file() function. I have it working now, with a bit of a work around, but would like to know what everyone thinks in...
3
by: SM | last post by:
Hello, I have an array that holds images path of cd covers. The array looks like this: $cd = array( 589=>'sylver.jpg', 782=>'bigone.jpg', 158=>'dime.jpg' );
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.