HTML showing but not PHP value

Problems with the Windows version of XAMPP, questions, comments, and anything related.

HTML showing but not PHP value

Postby traughber » 12. May 2011 21:19

Hi,

I searched the forums for an answer but couldn't find it. Seems like this should have already been posted, but all I can find is threads where people are trying to open the php file directly without loading it through the URL. That isn't what I did.

I installed XAMPP on Windows XP SP3 at work. Windows Firewall is disabled by a group policy and my machine is sitting behind a corporate firewall and proxy server.

Here's the steps I took followed by my problem:

1. I installed XAMPP version 1.7.4 by extracting the zip to a folder on my hard drive.

2. I ran the setup_xampp.bat.

3. Then I launched xampp-control.exe and started Apache and MySQL. See the screenshot here. http://dl.dropbox.com/u/2090992/Pictures/2011-05-12_130057.png

4. I created a folder inside of htdocs called learning_php and created a basic php file inside. Here's the code:
Code: Select all
<html>
<head>
    <title>Untitled Page</title>
</head>
<body>
What is your name: <br />

<?php
echo "Kris is my name.";
?>

</body>
</html>


5. Then I launched the localhost URL in Firefox 4. It showed the HTML text I added, but not the echoed PHP string. See screenshot here. http://dl.dropbox.com/u/2090992/Pictures/2011-05-12_131019.png


What am I missing?
traughber
 
Posts: 4
Joined: 12. May 2011 20:59

Re: HTML showing but not PHP value

Postby Altrea » 13. May 2011 00:18

Is your XAMPP Administration panel http://localhost/xampp/ working correct?
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11935
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: HTML showing but not PHP value

Postby Sharley » 13. May 2011 00:30

All works fine for me using all your posted information on an identical setup.

As posted above but also try a reboot and clear your browser's cache, check the C:\xampp\apache\logs\error.log file and the access.log files for possible clues and try in another browser.

Also disable any anti-virus scanners temporarily or apps. like ZoneAlarm, try again then if no difference enable the scanners again.
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: HTML showing but not PHP value

Postby traughber » 13. May 2011 04:39

I turned off anti-virus and cleared the cache in Firefox. XAMPP control panel looks good. See screenshot here http://dl.dropbox.com/u/2090992/Pictures/2011-05-12_203333.png

I also tried in in both IE 8 and IE 9.

Also, I'm now trying it at home on my Windows 7 laptop. It's the exact same installation as at work because I unzipped XAMPP to my Dropbox folder. I reran the setup_xampp.bat when I got home to refresh the paths. Everything looks like it's running as you can see from my screenshot. Is it my PHP syntax somehow? This is my very first attempt at writing any PHP whatsoever, but I didn't think I could screw up a simple echo command.
traughber
 
Posts: 4
Joined: 12. May 2011 20:59

Re: HTML showing but not PHP value

Postby Sharley » 13. May 2011 04:55

As i said, your code as posted works just fine on a default 1.7.4 installation and if as you say the Welcome Pages and demos work then PHP must be working fine in XAMPP.

Download a clean fresh copy of XAMPP for Windows Zip version and try again to install it on your laptop but make sure you uninstall the instance you have already installed from a copy of the one giving you strange results (could be corrupted), by following these instructions here:
viewtopic.php?p=179699#p179699

Good luck.
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: HTML showing but not PHP value

Postby Altrea » 13. May 2011 05:10

Are the example scripts in the administration panel working too?

If they are working too i would suppose any invisible characters in your code.
Maybe it's a Byte-Order-Mark issue.

But to be absolutely sure someone should take a look on to this file.
I will send you a PM with my email if you want me to take a look on this.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11935
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: HTML showing but not PHP value

Postby Sharley » 13. May 2011 05:37

Yes, could be a BOM occupying the first top most line of your code - what editor did you use to create the code and how did you save it?

In Windows Notepad saving it type all using ANSI Encoding will help.

These Google results may help understand what a byte order mark is.

Good luck.
Last edited by Sharley on 13. May 2011 05:43, edited 1 time in total.
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: HTML showing but not PHP value

Postby traughber » 13. May 2011 05:43

Altrea wrote:Are the example scripts in the administration panel working too?

If they are working too i would suppose any invisible characters in your code.
Maybe it's a Byte-Order-Mark issue.

But to be absolutely sure someone should take a look on to this file.
I will send you a PM with my email if you want me to take a look on this.


I was just getting ready to email you and I had a thought. I retyped the whole script in notepad and it worked! So there must have been something to your theory about invisible characters. So how do I stop it from happening again? I really don't want to do all of my development in notepad. :) When the problem happened I had written it using TotalEdit. It's a text editor like Notepad++ that has syntax highlighting and such. Have you seen behavior like that before where invisible characters were entered? How does that happen?

Anyway, problem solved. I'm going to find another editor or maybe an IDE like Netbeans.

Thanks for the help.
traughber
 
Posts: 4
Joined: 12. May 2011 20:59

Re: HTML showing but not PHP value

Postby Altrea » 13. May 2011 07:01

Open TotalEdit.
Menu -> Configure -> EditorProperties -> Document Settings -> uncheck "Persist BOM (Byte-Order-Mark)".

That should do the trick for new documents. But i don't really like TotalEdit. The configurations is far away from being clear and user friendly, in my opinion.
I really like Notepad++ or a full IDE like Eclipse or NetBeans. But you should use the editor you like most.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11935
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: HTML showing but not PHP value

Postby traughber » 13. May 2011 14:50

Altrea wrote:Open TotalEdit.
Menu -> Configure -> EditorProperties -> Document Settings -> uncheck "Persist BOM (Byte-Order-Mark)".

That should do the trick for new documents. But i don't really like TotalEdit. The configurations is far away from being clear and user friendly, in my opinion.
I really like Notepad++ or a full IDE like Eclipse or NetBeans. But you should use the editor you like most.


For doing PHP at work I just want a simple portable editor whereas I'll use a full IDE at home. I'm not particularly tied to TotalEdit. The only reason I chose TotalEdit was because it has the file browser on the side.
traughber
 
Posts: 4
Joined: 12. May 2011 20:59


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 74 guests