PHP not working
Posted by: Helgrimm (212.118.224.---)
Date: November 07, 2012 12:30PM

Hi all,

I have installed WAMP on my Win7 machine, started the services and the icon is green in the task bar. I cannot get PHP to do anything however, even display phpinfo();

I am accessing it through the browser (localhost:81/support/index.php)
Following the phpinfo(); on the WAMP page DOES work for some reason...
When I view the source code in Chrome I get hyphens in the php code oddly enough even though I did not put them there. (<!--?php
phpinfo();
?-->winking smiley

Here is my code:
<?php
phpinfo();
?>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div id="mainbody">

<h2> Can you see me? </h2>
<?php
echo 'hello';
?>
</div>
</body>
</html>

Any help on this I would be greatly appreciative! Been looking at this problem for hours...

Options: ReplyQuote
Re: PHP not working
Posted by: Helgrimm (212.118.224.---)
Date: November 07, 2012 12:34PM

Oh, something I forgot to mention, I had to change the port that apache uses to 81 in the httpd.conf file as something was already using port 80.

Options: ReplyQuote
Re: PHP not working
Posted by: RiggsFolly (---.ppp.as43234.net)
Date: November 07, 2012 02:16PM

The phpinfo call produces a complete html page.

Try createing a file with just that in it, like this.

filenae - myphpinfo.php

<?php
phpinfo();
?>

Does that run?

Options: ReplyQuote
Re: PHP not working
Posted by: Helgrimm (212.118.224.---)
Date: November 07, 2012 02:51PM

Yes it does... Very odd. So for some reason whenever I put php code along with html code (still keeping the .php ext) it turns the php tags into comments like in the first example. Any thoughts? I need to link to a database eventually.

Options: ReplyQuote
Re: PHP not working
Posted by: RiggsFolly (---.ppp.as43234.net)
Date: November 07, 2012 02:57PM

Well what is probably happening is that the phpinfo puts out a valid html page and then if you try to add a doctype line after that is output, ( which should always be the first line in any html page, not in the middle), its just upsetting the browser.

Options: ReplyQuote
Re: PHP not working
Posted by: Helgrimm (212.118.224.---)
Date: November 07, 2012 04:15PM

Thanks for your help on this by the way, appreciate it.

I've put a simple <?php echo "Hello"; ?> in the body of my html page, but when I load it up by going to localhost:81/support/index.php it is still not being displayed. When I "Inspect source" on Chrome, the code has changed to
<!--?php
echo "hello";
?-->
So it's like it has interpreted it as a comment. Is there perhaps a setting in wamp that fills in comments for you? Some sort of shortcut?

Options: ReplyQuote
Re: PHP not working
Posted by: RiggsFolly (---.ppp.as43234.net)
Date: November 08, 2012 03:21AM

Thats a new one on me.

Have you made any changes to your php.ini?

Options: ReplyQuote
Re: PHP not working
Posted by: Helgrimm (212.118.224.---)
Date: November 08, 2012 10:51AM

None. Only change I made is the port number in the Apache httpd.conf as port 80 was being taken by VMware.

Options: ReplyQuote
Re: PHP not working
Posted by: RiggsFolly (---.ppp.as43234.net)
Date: November 08, 2012 11:58AM

Can you post the whole php file thats causing the problem please.

Options: ReplyQuote
Re: PHP not working
Posted by: Helgrimm (212.118.224.---)
Date: November 08, 2012 11:59AM

Solution found: I'm using Sublime Text 2, which for some crazy reason was saving my files in an odd encoding. Switched it to UTF-8 and php is functioning correctly. Another result of my text editor using the wrong encoding was my .css file was displaying its source in foreign characters (which is what gave it away!)

Options: ReplyQuote
Re: PHP not working
Posted by: RiggsFolly (---.ppp.as43234.net)
Date: November 08, 2012 12:02PM

WEll doen and thanks for posting your solution.

Options: ReplyQuote


Sorry, only registered users may post in this forum.