[thelist] PHP - While Loop

John.Bedard at ngc.com John.Bedard at ngc.com
Thu Aug 14 10:27:39 CDT 2003

As a fellow PHP newbie, I had something similar happen. Turns out I forgot to put <? or <?php before my code. It just spewed out the raw code rather than processing it. I can't think of any other reason it would render the closing ?>, assuming your installation is correct. 

Oh, wait, shouldn't that first line also be:

"<tr>\n  <td align='right'>" . $distance. "</td>\n";

Or even:

"<tr>\n  <td align=\"right\">" . $distance. "</td>\n";



-----Original Message-----
From: Kath [mailto:Kath at cyber-kat.com]
Sent: Thursday, August 14, 2003 9:13 AM
To: thelist at lists.evolt.org
Subject: [thelist] PHP - While Loop

I'm just beginning to learn PHP using  PHP and MySQL Web Development by
Luke Welling and Laura Thomson.

I'm up to the Conditionals - While Loop section.  I opened an example they
have and it doesn't seem to work on my set up, though it does work if I
upload the file to my server.  I have an Apache/PHP 4.2.3/MySQL set up on
my Windows 2000 PC.

Here is the PHP code ...

$distance = 50;
while ($distance <= 250 )
  echo "<tr>\n  <td align='right'>$distance</td>\n";
  echo "  <td align='right'>". $distance / 10 ."</td>\n</tr>\n";
  $distance += 50; 

And this is the output on my PC ...

Distance Cost 
\n\n"; $distance += 50; } ?>  

I have no idea why it doesn't work in my testing environment.  Is there
something else I need on my system besides Apache/PHP 4.2.3/MySQL?

Is there more information I need to provide to more closely pinpoint the

I would love for the test environment to work so I don't have to keep
uploading these "learning" files to my web site.


Kath ...  "A patriot must always be ready to defend his country against its
government."  -Edward Abbey, naturalist and author (1927-1989)
Established 1995 --> www.cyber-kat.com

* * Please support the community that supports you.  * *

For unsubscribe and other options, including the Tip Harvester 
and archives of thelist go to: http://lists.evolt.org 
Workers of the Web, evolt ! 

More information about the thelist mailing list