Jump to content

Simple code not executing accurately


Go to solution Solved by deepspace,

Recommended Posts

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 by deepspace

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 by deepspace
<!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 by deepspace

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.

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 by deepspace

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 by deepspace
  • Solution

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 by deepspace
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.