Jump to content

noob problem with echo


epitaph

Recommended Posts

So I am just going through the book PHP and MySQL Web Development and I'm stuck in the first example. The problem is that the '; ?> part at the end of the <?php tag is getting printed on the page. Here is my html and php:

 

 

/html file

 

<form action="processorder.php" method="post">
<table border="0">
<tr bgcolor="#cccccc">
<td width="150">Item</td>
<td width="15">Quantity</td>
</tr>
<tr>
<td>Tired</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>
<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>

 

 

/php file

 

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

 

Thanks for your help

Link to comment
Share on other sites

you will want to include the php before the closing </body> tag

 

<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 submitted.</p>";
?>
</body>
</html>

Link to comment
Share on other sites

See the page source, maybe theres a hint what is going wrong. Also do you have PHP server installed on your system? It should print in both cases, outside and inside the body no matter what.

true it should, that was an educate matter, most likely you do not have a PHP server installed..?

As tendolla said, a view source in you browser should give you more of an understanding as to what the parser is doing, if you do have a PHP server installed that is

Link to comment
Share on other sites

Try directing your browser to http://localhost/yourfile.php

 

It sounds like you're clicking on the files themselves and viewing the raw php source code inside your browser.  Is that correct?

 

.php files need to be run through the php interpreter which should have been set up with your web server software, but in order to use it you have to open stuff through that server - by taking your browser to http://localhost/  (or http://127.0.0.1/ if that doesn't work)

 

Hope this helps!

 

,Travis

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.