eatc7402 Posted August 25, 2006 Share Posted August 25, 2006 I am confused (although some feel this is a normal condition)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 fileWITHOUT 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.inifor 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/maindir/sp_main.htm", "r");when local$handle = fopen("http://www.mysite.org/sp_main.htm/", "r");when remoteAlso as a test I have included this codeecho "<a href=\"sp_main.htm\">sp_main_link</a>";which works FINE, as I expectedBut when executing the php fopen() code on the local OR remoteI get NO ERRORS reported, but also NO link to the filedesired, just a blank screen.I don't quite understand what is wrong. Any ideas??eatc7402 Quote Link to comment https://forums.phpfreaks.com/topic/18648-php-fopen-confusion/ Share on other sites More sharing options...
wildteen88 Posted August 25, 2006 Share Posted August 25, 2006 fopen wont display anything. It just opens the file ready for being edited or read by PHP.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. Quote Link to comment https://forums.phpfreaks.com/topic/18648-php-fopen-confusion/#findComment-80375 Share on other sites More sharing options...
eatc7402 Posted August 25, 2006 Author Share Posted August 25, 2006 fopen() binds a named resource, specified by filename, to a stream. If filename is of the form "scheme://...", it is assumed to be a URL and PHP will search for a protocol handler (also known as a wrapper) for that scheme. If no wrappers for that protocol are registered, PHP will emit a notice to help you track potential problems in your script and then continue as though filename specifies a regular file.================================================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 htmlfile 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 CLICKEDbut actually not clicking. An 'automatic' linl call.How can that be done??eatc7402 Quote Link to comment https://forums.phpfreaks.com/topic/18648-php-fopen-confusion/#findComment-80480 Share on other sites More sharing options...
eatc7402 Posted August 25, 2006 Author Share Posted August 25, 2006 I solved my problem...Use the [color=red]header()[/color] 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 willget CANNOT MODIFY THE HEADER errors.eatc7402 Quote Link to comment https://forums.phpfreaks.com/topic/18648-php-fopen-confusion/#findComment-80506 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.