Php fopen() confusion
Posted 25 August 2006 - 03:08 PM
over the use of the fopen() function.
I am using Windows XP, and both IIS (locally), and Apache
(on the remote server). I am trying to get the equivelent of
an 'auto-link' (instead of the manual mouse click type) to
another .htm file in the 'main' directory.
In other words a link that goes to the selected .htm file
WITHOUT a mouse click, by using the fopen() function.
Am I all wet in trying to do it that way??
I am using PHP 4.3.10, and the user attribute in phi.ini
for allow_url_fopen is turned ON, indicated by phpinfo.
I have a small php script called by a form select button,
which in turn fopen's the desired file.
the php code (partial) looks likw this
$handle = fopen("http://localhost/mai...ir/sp_main.htm", "r");
$handle = fopen("http://www.mysite.or...g/sp_main.htm/", "r");
Also as a test I have included this code
echo "<a href=\"sp_main.htm\">sp_main_link</a>";
which works FINE, as I expected
But when executing the php fopen() code on the local OR remote
I get NO ERRORS reported, but also NO link to the file
desired, just a blank screen.
I don't quite understand what is wrong. Any ideas??
Posted 25 August 2006 - 03:51 PM
To read the file you use fread, to edit the file your use fwrite.
if you want to display the contents of the file as part of the php gile use include or require.
Posted 25 August 2006 - 09:29 PM
The php documentation (above) seems to indicate that if the file name contains an 'http:'
it will be treated 'special'. I assumed thats means to try to execute it it as an html
file in a cbrowser. True or false????
Maybe I am approaching this all wrong.
What I desire is to get an html link command '<a></a>' to execute AS IF WAS CLICKED
but actually not clicking. An 'automatic' linl call.
How can that be done??
Posted 25 August 2006 - 10:34 PM
Use the header() commend instead of the fopen to get
an EXTERNAL HTML FILE to run.
Just be careful NOT to include ANY html form tags in the php script your running or you will
get CANNOT MODIFY THE HEADER errors.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users