deepspace Posted February 8, 2014 Share Posted February 8, 2014 (edited) I am just barely learning. I enter this code echo '<h1>Hello World!</h1>'; and it comes out like this Hello World!';?> and does'nt recognize the h1 tag unless there is more than one line. HELP Edited February 8, 2014 by deepspace Quote Link to comment https://forums.phpfreaks.com/topic/286040-simple-code-not-executing-accurately/ Share on other sites More sharing options...
ginerjm Posted February 8, 2014 Share Posted February 8, 2014 Did you begin your code with a php tag? Quote Link to comment https://forums.phpfreaks.com/topic/286040-simple-code-not-executing-accurately/#findComment-1468188 Share on other sites More sharing options...
deepspace Posted February 8, 2014 Author Share Posted February 8, 2014 (edited) Maybe I need to give more info. I am woeking on local machine using WINXP svcpk3 and XAMPP with notepad ++ as my editor. This is my code exactly as I put it in notepad++. <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <?php echo "<h1>Hello World!</h1>" ; ?> <php? "<h1>Second Heading Block</h1>" ?> <?php echo "<h2>Hello World!</h2> <br> <b>This text bold!</b>" ; ?> <?php echo "<h1>Third Heading Block</h1>" ; ?> </body> </html> This is exactly how it opens in the browser. Hello World!' ; ?> Second Heading Block' ?> Hello World! This text is bold!' ;(and it is) ?> Third Heading Block' ; ?> Thankx for reply Edited February 8, 2014 by deepspace Quote Link to comment https://forums.phpfreaks.com/topic/286040-simple-code-not-executing-accurately/#findComment-1468189 Share on other sites More sharing options...
ginerjm Posted February 8, 2014 Share Posted February 8, 2014 And your question is??? Probably the "second heading" line, no? Look closely and you should see your typo. Quote Link to comment https://forums.phpfreaks.com/topic/286040-simple-code-not-executing-accurately/#findComment-1468191 Share on other sites More sharing options...
deepspace Posted February 8, 2014 Author Share Posted February 8, 2014 (edited) OK I corrected the typo and it makes little difference on my local machine. It simply adds the semi colon to the end of that line. Also, I have a laptop with WIN 7. Using the exact same above procedure, the end results are the same. I might note that I have uploaded these pages to my web hosting page graphicsguy.us and the page opens up the way it should. Like this: Hello World! Second Heading Block Hello World! This text bold! Second Heading Block The problem is on my local machine. I really appreciate your help. Don't stop. Thanx. If you like you can go to my website and open up sample.php . There is no link. Edited February 8, 2014 by deepspace Quote Link to comment https://forums.phpfreaks.com/topic/286040-simple-code-not-executing-accurately/#findComment-1468195 Share on other sites More sharing options...
ginerjm Posted February 8, 2014 Share Posted February 8, 2014 Show us the revised code in its entirety. Quote Link to comment https://forums.phpfreaks.com/topic/286040-simple-code-not-executing-accurately/#findComment-1468196 Share on other sites More sharing options...
deepspace Posted February 8, 2014 Author Share Posted February 8, 2014 (edited) <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <?php echo '<h1>Hello World!</h1>' ; ?> <?php echo '<h1>Second Heading Block</h1>' ; ?> <?php echo '<h2>Hello World!</h2><b>This text bold!</b>' ; ?> <?php echo '<h1>Third Heading Block</h1>' ; ?> </body> </html> Now the code opens up like this: Hello World!" ; ?> Second Heading Block" ; ?> Hello World!This text bold!" ; ?> Third Heading Block" ; ?> Edited February 8, 2014 by deepspace Quote Link to comment https://forums.phpfreaks.com/topic/286040-simple-code-not-executing-accurately/#findComment-1468197 Share on other sites More sharing options...
ginerjm Posted February 8, 2014 Share Posted February 8, 2014 This is a cleaned up version of your php code: <?php echo '<h1>Hello World!</h1>'; echo '<h1>Second Heading Block</h1>'; echo '<h2>Hello World!</h2><b>This text bold!</b>'; echo '<h1>Third Heading Block</h1>'; ?> Nothing wrong with this code. If it doesn't work on your environment, suspect the environment, not the script. BTW - you mentioned that the correction simply added a semicolon. I don't see in this code where any semi could possible be showing up. BTW2 - you realize that you don't need php to display your sample outputs? It's all plain html, so the <? and the echo's are not needed. Quote Link to comment https://forums.phpfreaks.com/topic/286040-simple-code-not-executing-accurately/#findComment-1468199 Share on other sites More sharing options...
deepspace Posted February 8, 2014 Author Share Posted February 8, 2014 (edited) I am simply going by the tutorial that I have, and this is the way it was given to me. And you are right about it being my local environmet. I never doubted that. I just hoped that maybe you had seen this problem before. I can live with this problem if I have to. I just thought that maybe someone could find a solution. If not then your help is tremendously appreciated. I will carry on, bearing in mind that the code that I write will execute properly on my web server. I will just have to do the best that I can. I am going to try the code the way you gave it to me and see what happens. I have another computer beside me that I am working on. When I change the code I will send back the result. Thanx. Very newbie deepspace. PS keep in touch. OK I have made your changes. No longer is everything on one line, but the delimiters are still there as well as the semi colons and the "echo" statements. PERPLEXED. Edited February 8, 2014 by deepspace Quote Link to comment https://forums.phpfreaks.com/topic/286040-simple-code-not-executing-accurately/#findComment-1468206 Share on other sites More sharing options...
mac_gyver Posted February 8, 2014 Share Posted February 8, 2014 what url are you using in your browser to access your localhost development system, it should be something like - http://localhost/your_file.php Quote Link to comment https://forums.phpfreaks.com/topic/286040-simple-code-not-executing-accurately/#findComment-1468207 Share on other sites More sharing options...
deepspace Posted February 8, 2014 Author Share Posted February 8, 2014 (edited) http://www.graphicsguy.us/sample.php unless you mean this http://localhost/users/user1/xampp/htdocs/intro2php/sample.php That doesn't work so I am having to open documents by using the hotkeys ctrl-o in Chrome or file-Open in Firefox. Edited February 8, 2014 by deepspace Quote Link to comment https://forums.phpfreaks.com/topic/286040-simple-code-not-executing-accurately/#findComment-1468210 Share on other sites More sharing options...
mac_gyver Posted February 8, 2014 Share Posted February 8, 2014 that's the url for your live server. go back and read what i wrote. Quote Link to comment https://forums.phpfreaks.com/topic/286040-simple-code-not-executing-accurately/#findComment-1468211 Share on other sites More sharing options...
deepspace Posted February 8, 2014 Author Share Posted February 8, 2014 (edited) graphicsguy.us/sample.php I've tried every combination. Nothing works except to open it the way I said. Cntrl+o in chrome and File + open file in Firefox Edited February 8, 2014 by deepspace Quote Link to comment https://forums.phpfreaks.com/topic/286040-simple-code-not-executing-accurately/#findComment-1468220 Share on other sites More sharing options...
Solution deepspace Posted February 8, 2014 Author Solution Share Posted February 8, 2014 (edited) Guess what? I tried another combination. http://intro2php/sample.php and it works without all the unnecessary bull Hello World! Second Heading Block Hello World! This text bold! Third Heading Block This is how it opens in my browser. I guess I just needed to take a break and come back and pay attention to what I was doing, which I could not do without your help. You don't know how much you have done for me. If ever I can help you just let me know. Access my website graphicsguy.us and email me. I will do my best to help you. Much thanx. deepspace By the way. The php files that are on my site were created by free php builder sites. Some are better than others, Edited February 8, 2014 by deepspace Quote Link to comment https://forums.phpfreaks.com/topic/286040-simple-code-not-executing-accurately/#findComment-1468222 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.