Page 1 of 1

Newbie PHP Help with PHP: Echo and IE

Posted: Thu Jul 08, 2010 10:39 pm
by WillAddison
I am working with "PHP and MySQL Web Development Fourth Edition" book. I was able to install PHP, Apache and get a test PHP script using <? phpinfo(); ?> and get the display info to work.

I tried to use the first example from the book and am getting some errors.

I am using the following HTML:

<html>
<title>Bob's Autoparts</title>
<body>
<form action="processorder.php" method="post" />
<table border="0">
<trbgcolor="#cccccc">
<td width="150">Item</td>
<td width="15">Quantity</td>
</tr>
<tr>
<td>Tires</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>Spark 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>
</body>
</html>


The php code is as follows:

<html>
<head>
<title>Bob's Auto Parts - Order Results</title>
</head>
<body>
<h1>Bob's Auto Parts</h1>
<h2>Order Results</h2>
<?php
echo "<p>Order processed.</p>";
?>
</body>
</html>

When this code runs in IE 8, it displays the PHP script only when I click on the submit. In Firefox, the code displays the following:

Bob's Auto Parts
Order Results
Order processed.

"; ?php>


Is there something causing IE to not process the code at all? What is causing the extra "; ?php> at the end?

Thanks,

Will

Re: Newbie PHP Help with PHP: Echo and IE

Posted: Thu Jul 08, 2010 10:44 pm
by requinix
Just to get this straight: PHP and IE have nothing to do with each other. Absolutely nothing.
WillAddison wrote:When this code runs in IE 8, it displays the PHP script only when I click on the submit.
That's the correct behavior, if you were wondering.

If you do a View Source on that page, what do you see? Do you see the PHP code? That means it wasn't being executed. What's different between the phpinfo() page you did and this new one?

Re: Newbie PHP Help with PHP: Echo and IE

Posted: Fri Jul 09, 2010 4:51 pm
by WillAddison
Nevermind, my friend assisted. I was not starting the page from the localhost causing the php not to execute. Thanks....
:oops: