PDA

View Full Version : Cannot get php script to run properly on local machine



wkenny
10-18-2005, 10:32 PM
I've downloaded and installed php v5 on to a Windows 2000 pc. If I run the following
<?php
phpinfo();
?>

in c:\inetpub\wwwroot it returns all the configuration data.

but if I run the following in C:

<html>
<head>
<title>Billy's Auto Parts - Order results</title>
</head>
<body>
<h1> Billy's Auto Parts</h1>
<h2>Order results</h2>

<?php
echo '<p>order 2 processed</p>' ;
?>
</body>
</html>

the echo shows nothing in IE6 and shows

order 2 processed

' ; ?>

in Mozilla. I have tried changing <?php ?> to <script language="php"></script> but get no echo in IE6 or Mozilla.

I can't believe I'm stuck at what is essentially "hello world". :confused:

I've tried changing the single quotes after echo to doubles but the reults are the same (except Mozilla now shows the closing double quote).

Help, please

Twey
10-19-2005, 03:12 PM
You are accessing the page via your webserver, aren't you? It won't be parsed as PHP otherwise.

wkenny
10-19-2005, 05:36 PM
Hi Twey

As far as I know I am. I have edited the config file for windows and added php to servers.

Or do I have to make an explicit to something?

Twey
10-19-2005, 05:42 PM
How do you access the page? Describe the steps.

wkenny
10-19-2005, 08:16 PM
I have a simple form called test.htm and processorder in inetpub/wwwroot
<!--test.htm-->
<form action="processorder.php" method="post">
<table>
<tr bgcolor="#ccccc">
<td width="150">Item</td>
<td width="15">Quantity</td>
</tr>
<tr>
<td>Tyres</td>
<td align="center"><input type="text" name="tireqty" size="3" maxlength="3" /></td>
</tr>
<tr>
<td>Oil</td>
<td align="center"><input type="text" name="oilqty" size="3" maxlength="3" /></td>
</tr>
<tr>
<td>Plugs</td>
<td align="center"><input type="text" name="sparkqty" size="3" maxlength="3" /></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="Submit Order " /> </td>
</tr>
</table>
</form>

and processorder.php is

<html>
<head>
<title>Billy's Auto Parts - Order results</title>
</head>
<body>
<h1> Billy's Auto Parts</h1>
<h2>Order results</h2>

<?php
echo '<p>order 2 processed</p>' ;
?>
</body>
</html>

blm126
10-19-2005, 11:51 PM
No,what I think Twey means is are you using a webserver. It's not enough to have PHP installed you also need a webserver such as Apache. You can't just acces the pages like you would for an html file.

wkenny
10-20-2005, 12:12 AM
I'm using IIS as the webserver.

PHP.net provide a version which runs under IIS, which is what I've downloaded. They also have a Windows installer which is what I used to install. I read the install notes and followed the instructions there for modifying the config (php.ini) file.

I have followed all the advised steps. I have the PHP dll (running as a cgi-exe rathe rthan ISAPI - can't remember the name off the top of my head) in the environment path.

I've read the installation notes, checked out posts here, read the PHP and Microsoft sites and have tried to extract from them all what needs to be done and am stumped.

Unless I've totally misunderstood all the documentation, I do not need Apache as PHP should run under IIS (which it obviously does when I run phpinfo() without a problem.

Twey
10-20-2005, 06:11 PM
Yes, it seems to run fine for the phpinfo() test, but not parse the PHP for the other. Does it work if you put the "Hello" test under the same directory as the phpinfo()?

wkenny
10-20-2005, 08:08 PM
No, I've tried that - sorry, I should have stated so originally.

wkenny
10-20-2005, 08:41 PM
Getting somewhere.

If I type

http://localhost/processorder.php

in the browser address box the script runs ok. I can live with this.

Thanks to all who have tried to help.