472,143 Members | 1,525 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,143 software developers and data experts.

My Test PHP File Cannot Display in the Browser Window

To tell you the truth, basically I am nobody insofar as scripting PHP
is concerned. However, I fell in love with the language after reading
great things about what the language can do, and so I downloaded and
installed PHP5 and set up to work with Apache 2 on my PC according to
the instructions set forth at http://www.php.net.

I embedded a test php script inside an html file which is something
like this:

<html>
<head> <title>Tesing PHP Scripting </title> </head>
<body>
Testing PHP Scripting:<br>
<?
phpinfo();
?>
</body>
</html>

and saved it as
test.php
in the
Apache Group\Apache2\htdocs
directory.

When I tried to run the file in IE6, instead of outputting the result
in the browser screen, the test.php file -text file(the sourse
code)opens up in the text editor that i used to create it. I just don't
know what is going on, and I don't know where to go from here in my
quest to learn PHP.

Any help from you good people?
Jofio

Jul 17 '05 #1
4 21056
Jofio wrote:

To tell you the truth, basically I am nobody insofar as scripting PHP
is concerned. However, I fell in love with the language after reading
great things about what the language can do, and so I downloaded and
installed PHP5 and set up to work with Apache 2 on my PC according to
the instructions set forth at http://www.php.net.

I embedded a test php script inside an html file which is something
like this:

<html>
<head> <title>Tesing PHP Scripting </title> </head>
<body>
Testing PHP Scripting:<br>
<?
phpinfo();
?>
</body>
</html>

and saved it as
test.php
in the
Apache Group\Apache2\htdocs
directory.

When I tried to run the file in IE6, instead of outputting the result
in the browser screen, the test.php file -text file(the sourse
code)opens up in the text editor that i used to create it. I just don't
know what is going on, and I don't know where to go from here in my
quest to learn PHP.

Any help from you good people?


There are several errors here:

1) You better don't use short tags. PHP can be configured not to accept
them and if you don't know how your PHP (or the PHP version on the
server the script is supposed to run in the end) is configured you
should only use "<?php" instead of "<?".

2) The function phpinfo() returns a whole webpage with info about the
installed PHP version and its configuration. Don't embrace it with HTML
tags. Your testscript should therefore look like this:

<?php
phpinfo();
?>

3) You don't run php files in your browser. The server runs them and
delivers the result to your browser. You will have to access the file
through the server using:

http://127.0.0.1/test.php

4) If that does not work make sure that ...

4a) ... the Apache server is running.
4b) ... Apache is really configured to deliver the pages from the
htdocs directory. (Should be by default, but perhaps you changed that
and forgot about it.)
4c) ... Apache is really configured to use PHP.

If 4a) fails you will see an IE error message that it can't access the
page. If 4b) fails IE will show you an error message it received from
Apache, that it can't find the requested file. In case of 4c) failing IE
will show you what it received from Apache: The PHP sourcecode as text.

That should get you going for the start.

Bye!
Jul 17 '05 #2
"Jofio" <j9******@yahoo.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com...

When I tried to run the file in IE6, instead of outputting the result
in the browser screen, the test.php file -text file(the sourse
code)opens up in the text editor that i used to create it. I just don't
know what is going on, and I don't know where to go from here in my
quest to learn PHP.

Any help from you good people?


You can't open the file directly - you have to go through the server.

Assuming your server (that Apache and PHP are on) is the same machine as the
one you're using to view, you need to open http://localhost/<PHP-path>

If your PHP test script is in the wwwroot directory, that would be
http://localhost/testfile.php

with "testfile.php" being whatever file name you used.

--
Tony Garcia
www.dslextreme.com/~tony23/
Jul 17 '05 #3
Thanks so much, Tony.

I tried a) http://localhost/test.php
and
b) http://ipAddress/test.php

and both worked. Now I'll jump into the php wagon and try riding.

jofio

Jul 17 '05 #4
Thanks so much.

Infact http://myIPaddress/test.php and http://localhost/test.php both
worked.

jofio

Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by chazmanian | last post: by
4 posts views Thread by Franck Diastein | last post: by
1 post views Thread by bbulsara23 | last post: by
3 posts views Thread by bfmcfarlane | last post: by
5 posts views Thread by DrNoose | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.