954,561 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

problem with php mixed with html

I have this file x.php but it doesnt work. Php only works if it is in a pure php file
(with no html code).Im using xampp 1.7.7. Any ideas what might be the problem ?

<html>

<body>

<?php
echo ("HELLO");

?>
</body>

</html>
yanwick
Newbie Poster
21 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

Works fine on my system: Fedora 15, Firefox 9, Apache 2.x on localhost. I think it should run on other systems too. What error do you get?. If you look at the page source in the browser is there anything displayed? What do you get if you add some text to the html code such as below?

<html>

<body>

<h1>Do you see HELLO WORLD or just WORLD?</h1>

<?php
echo ("HELLO");
?>

<span> WORLD</span>

</body>

</html>
broj1
Posting Whiz
359 posts since Jan 2011
Reputation Points: 29
Solved Threads: 43
 

What it shoes is <?echo ('hello')?> but i ve tried in another computer with windows vista and it works fine,(im using xp professional).

Works fine on my system: Fedora 15, Firefox 9, Apache 2.x on localhost. I think it should run on other systems too. What error do you get?. If you look at the page source in the browser is there anything displayed? What do you get if you add some text to the html code such as below?

<html>

<body>

<h1>Do you see HELLO WORLD or just WORLD?</h1>

<?php
echo ("HELLO");
?>llo

<span> WORLD</span>

</body>

</html>
yanwick
Newbie Poster
21 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

Did you use PHP short tags (as it is displayed in your last post)? Maybe your web server is not configured for short tags. Also it might be a good idea to put a whitespace between the tags and PHP code.

broj1
Posting Whiz
359 posts since Jan 2011
Reputation Points: 29
Solved Threads: 43
 

i don't see something wrong with your code....what's the error?

vaultdweller123
Posting Pro
554 posts since Sep 2009
Reputation Points: 42
Solved Threads: 75
 
<?php
phpinfo();
?>

What does it return ? Also, don't put the bracket withecho statement.

<?php
echo "Hello";
?>

It should be.

Zero13
Practically a Master Poster
624 posts since Jan 2009
Reputation Points: 120
Solved Threads: 139
 

how are you accessing the file
it appears a localhost error

almostbob
Posting Sensei
3,149 posts since Jan 2009
Reputation Points: 571
Solved Threads: 376
 

Thank you all. I solved the problem by saving the file in a php editor program.The file was formatted using wordpad.Plus i installed the windows 7.

yanwick
Newbie Poster
21 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You