epitaph Posted July 25, 2011 Share Posted July 25, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/242770-noob-problem-with-echo/ Share on other sites More sharing options...
AyKay47 Posted July 25, 2011 Share Posted July 25, 2011 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> Quote Link to comment https://forums.phpfreaks.com/topic/242770-noob-problem-with-echo/#findComment-1246912 Share on other sites More sharing options...
epitaph Posted July 25, 2011 Author Share Posted July 25, 2011 I'm sorry I started with that and I moved it outside of the html tags to see if that was messing that up. I am still getting "; ?> returned on my page. Quote Link to comment https://forums.phpfreaks.com/topic/242770-noob-problem-with-echo/#findComment-1246914 Share on other sites More sharing options...
TeNDoLLA Posted July 25, 2011 Share Posted July 25, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/242770-noob-problem-with-echo/#findComment-1246918 Share on other sites More sharing options...
AyKay47 Posted July 25, 2011 Share Posted July 25, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/242770-noob-problem-with-echo/#findComment-1246921 Share on other sites More sharing options...
epitaph Posted July 25, 2011 Author Share Posted July 25, 2011 I never installed php on my system. Do I need to install it in order for firefox to read it correctly? Is there a directory that it needs to be installed in? Thanks for all your help. Quote Link to comment https://forums.phpfreaks.com/topic/242770-noob-problem-with-echo/#findComment-1246922 Share on other sites More sharing options...
AyKay47 Posted July 25, 2011 Share Posted July 25, 2011 there a various resources on this matter http://www.google.com/#sclient=psy&hl=en&source=hp&q=linux+php5+install&pbx=1&oq=linux+php5+install&aq=f&aqi=g1g-v1&aql=&gs_sm=e&gs_upl=1707l5552l0l5714l20l14l0l0l0l2l989l7151l3-2.1.4.4l11&bav=on.2,or.r_gc.r_pw.&fp=b1778f3db6f45f54&biw=837&bih=287 Quote Link to comment https://forums.phpfreaks.com/topic/242770-noob-problem-with-echo/#findComment-1246924 Share on other sites More sharing options...
wildteen88 Posted July 25, 2011 Share Posted July 25, 2011 You need install a server environment (known as the AMP stack) in order to run PHP code. There are couple of packages you can install called wamp or XAMPP. Read their document for where to place your php files. You then go to http://localhost/ to run them. EDIT: corrected the link to XAMPP. Quote Link to comment https://forums.phpfreaks.com/topic/242770-noob-problem-with-echo/#findComment-1246926 Share on other sites More sharing options...
epitaph Posted July 25, 2011 Author Share Posted July 25, 2011 Thanks guys I am going to install wamp server. Quote Link to comment https://forums.phpfreaks.com/topic/242770-noob-problem-with-echo/#findComment-1246929 Share on other sites More sharing options...
epitaph Posted July 25, 2011 Author Share Posted July 25, 2011 So i installed wampserver and put the php and html files in my www folder but the same problem is coming up. Any ideals? Quote Link to comment https://forums.phpfreaks.com/topic/242770-noob-problem-with-echo/#findComment-1246935 Share on other sites More sharing options...
wildteen88 Posted July 25, 2011 Share Posted July 25, 2011 You are going to http://localhost to run your html/php file. You cannot load the php file directly into your web browser. It needs to be requested from localhost. Quote Link to comment https://forums.phpfreaks.com/topic/242770-noob-problem-with-echo/#findComment-1246938 Share on other sites More sharing options...
epitaph Posted July 25, 2011 Author Share Posted July 25, 2011 Thanks problem fixed. Thank you all so much for helping me. Quote Link to comment https://forums.phpfreaks.com/topic/242770-noob-problem-with-echo/#findComment-1246939 Share on other sites More sharing options...
travishpa Posted July 25, 2011 Share Posted July 25, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/242770-noob-problem-with-echo/#findComment-1246941 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.