[thelist] PHP - While Loop

Ryan Tames rytames at telusplanet.net
Sun Aug 17 11:14:56 CDT 2003


On 17 Aug 2003 at 10:27, Kath wrote:

You know, it all depends on what kind of set-up you want:

Adding the ScriptAlias, and application-httpd mime types,
is the least secure manner that a webserver can run PHP.
Adding PHP as a module the web server runs, is more secure,
according to the PHP site.

The set-up is also defined by which version of PHP you installed.

The self install version, only comes with ScriptAlias (which is a CGI addition),
and zipped file version, which you install yourself, you can have both,
CGI or as a module.

> >php -i
> >php -v

You type those commands In a command console (cmd.exe), or 
in 'start->run' if you perfer that the command line display disapears.

Note: http.conf was a typo. httpd.conf is correct.

I see no reason why that one PHP file should not run properly.
and for some reason, I never get any sort of attachments through
this mailing list.

But that's OK, becouse you posted that information once before,
and that looks fine to me:

--------------
<table border="0" cellpadding="3">
<tr>
  <td bgcolor="#CCCCCC" align="center">Distance</td>
  <td bgcolor="#CCCCCC" align="center">Cost</td>
</tr>
<?
$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; 
}
?>
</table>
-------------

Thats what you got on a 'view source', which means the PHP script
is not being interpeted. I assume you mean 'view source' after
you run the script via your local web server.

You added ScriptAlias et al, to your local web server set-up,
thus every thing should run via the Common Gateway Interface.

Thats good. Now, You have to check to make sure 3 things:

1) The PHP script is ending with a .php and not .htm, or .html,
or anything else.

2) The the PHP script is located under the webservers 'document root'
directory, which is generally drive:/apache_installed_here/htdocs/
(theres a manual there, unless you removed it or set the document root
somewhere else).

3) That you are simply not opening the file with your web browser,
with out any sort of network negotiation with the webserver (becouse
the web server cannot get the file interpeted, if the file is not being loaded
via the server), so you'll need a URL: http://localhost/php_file.name

Some notes:

1) .php is a general (mime type) setup, to get more specific in script
interpeting, you need to add more lines to your web servers conf file.

2) When you add 'AddType' lines to Apache' conf file,  those
mime types are only visible the the apache(the web server) while
it runs.

3) CGI, is a software based gateway that allows a client to access
data through the web server. For more info, google for CGI 1.1




More information about the thelist mailing list