Php doesn't work in browser

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
johnorork
Forum Newbie
Posts: 5
Joined: Wed Feb 05, 2014 3:58 am

Php doesn't work in browser

Post by johnorork »

Hi ,
I have a windows vista service pack 2 system. I am running IIS and I have mysql installed and working. I ran the web platform installer and it created a subdirectory in c:\program files\iis express\PHP\v5.4. I also have changed the file defaults to point .php files to the php.exe in the this subdirectory I just referred to. When I get to the command line interpreter via cmd.exe I execute the command php -i and that works. If I make a small php script and type "php test.php" , that works also. However, if i go to the browser and execute a file with .html extension that has mixed html and php code, that only executes the html portion of the code in the chrome browser. Also if i just get into the php interpreter I don't get a prompt telling me I am there and nothing seems to execute there even though I put in valid php code. It just doesn't answer at all. This is IIS 7 and PHP 5.4 .

Thanks for any help
pbs
Forum Contributor
Posts: 230
Joined: Fri Nov 07, 2008 5:31 am
Location: Nashik, India
Contact:

Re: Php doesn't work in browser

Post by pbs »

can you please post your code here
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Php doesn't work in browser

Post by Celauran »

johnorork wrote:If I make a small php script and type "php test.php" , that works also. However, if i go to the browser and execute a file with .html extension that has mixed html and php code, that only executes the html portion of the code in the chrome browser.
What if you use the .php file extension?
johnorork
Forum Newbie
Posts: 5
Joined: Wed Feb 05, 2014 3:58 am

Re: Php doesn't work in browser

Post by johnorork »

<!DOCTYPE html>
<html>
<body>

<h1>My first PHP page</h1>

<?php
echo "Hello World!";
?>

</body>
</html>
Also I ran this in c:\inetpub\wwwroot\testp.php and it still only exectes the html code (displays the header).
johnorork
Forum Newbie
Posts: 5
Joined: Wed Feb 05, 2014 3:58 am

Re: Php doesn't work in browser

Post by johnorork »

Here is a new piece of information: When I went into the IIS Manager and used the Handler Mappings function I selected the Php54_via_FastCGI handler. I just looked at it and pressed ok. The Manager popped up an error saying that if I had spaces in anywhere in the pathname to the file that I should use double quotes. I tried that but nothing improved so I tried to use %20 for the space and that let me out of the error loop. I tried the .php program again but it still didn't work.
johnorork
Forum Newbie
Posts: 5
Joined: Wed Feb 05, 2014 3:58 am

Re: Php doesn't work in browser

Post by johnorork »

Since the IIS program is complaining about the space in the name of the files (program files and iis express) maybe it would be better to put the files and the initialization file for php in C:PHP so there would be less chance of an error? Just wondering.
johnorork
Forum Newbie
Posts: 5
Joined: Wed Feb 05, 2014 3:58 am

Re: Php doesn't work in browser

Post by johnorork »

Hi,
I uninstalled Php in the Program Files directory and reinnstalled it in the c:\php directory and changed all environment variables and appropriate references and pointers and php 5.5.9. now works well. It works in the command line and works in the browser and works with mixed html and php code . Even entering php from the command line and putting in code in php will work once I press control-c. That is maybe my last question. Is there supposed to be a php prompt when you get into the interpreter? Anyways thanks for not answering - it forced me to think things out on my own.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Php doesn't work in browser

Post by Celauran »

My guess is nobody answered because nobody uses IIS. To answer the one question I can answer, yes, PHP displays a prompt in interactive mode.

Code: Select all

[~]$ php -a
Interactive mode enabled

php > $date = new DateTime();
php > echo $date->format('F j, Y') . "\n";
February 6, 2014
php > 
Post Reply