473,403 Members | 2,284 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 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 21555
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
by: CHIN | last post by:
Hi all.. here s my problem ( maybe some of you saw me on other groups, but i cant find the solution !! ) I have to upload a file to an external site, so, i made a .vbs file , that logins to...
1
by: chazmanian | last post by:
We have a situation where we display PDF files through IE via a method in our code-behind as follows protected void displayPDF(string exePath, string filePath { // exePath is the...
7
by: TLM | last post by:
I am trying to build a web application that will contain links to files on a users local computer. I am assuming that the files will be in a known location and can display in a browser window. ...
4
by: Franck Diastein | last post by:
Hi, I'm trying to send a file to the browser with Response.Write, and it works great. The problem (I guess...) is that the code that sends the file is in a class, and whan I load aspx file...
1
by: bbulsara23 | last post by:
Hi, this has been asked so many times before but I cannot get an answer that works. So I'm asking again. I am using .Net 1.1 on a Windows XP Pro.
5
by: Neil Rossi | last post by:
I have an issue with a particular ASP page on two web servers. Let's call these servers Dev1 and Beta1. Both Servers are running IIS 5, Windows 2000 SP4 with "almost" all of the latest patches. ...
2
by: Lyle Fairfield | last post by:
I am using Microsoft’s Web Browser Control embedded on an Access Form to browse a specific site. I have a good reason for doing so; the pages on this site run code which aborts their display unless...
3
by: bfmcfarlane | last post by:
I have an appication that allows users to upload and download files. This application is only accessed when a user clicks on an "Upload / Download" link from within our main application. A new...
5
by: DrNoose | last post by:
Hi! I may have made this post several weeks back, but not sure. I have a project due Thurs. The problem is when I copy the file the the local inetpub/wwwroot folder and try to run the aspx...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.