GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 06-May-2004, 04:32
dopee dopee is offline
Awaiting Email Confirmation
 
Join Date: Feb 2004
Location: south africa
Posts: 109
dopee will become famous soon enough

unable to access


right so I have a new.php file which is mainly html text, other than the include: <?php include("admin/showleftmenu.php");?>.

Now when I run new.php from the broswer, it gets stuck in a loop cos the showleftmenu.php file gives the following errors:

<b>Warning</b>: fopen(): Unable to access lmenu.txt in <b>/new/admin/showleftmenu.php</b> on line <b>7</b>
<b>Warning</b>: fopen(lmenu.txt): failed to open stream: No such file or directory in /new/admin/showleftmenu.php</b> on line <b>7</b>

etc etc.

At first I thought it was cos the lmenu.txt file had the wrong permissions but I changed that and i'm still having probs.

This is the code in the showleftmenu.php file:
PHP Code:

<?php

// php script used to display content of text file
$leftMenu = "lmenu.txt";
$lfilePointer = fopen($leftMenu, "r+");
while (!feof($lfilePointer))
{
             $line = fgets($lfilePointer, 4096);
             print $line;
}
fclose($lfilePointer);
?>

Anyone pls??
Last edited by dsmith : 06-May-2004 at 09:00. Reason: Please use [php] & [/php] for syntax highlighting
  #2  
Old 06-May-2004, 11:07
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
Dopee, I really don't get it why you need to include ONE file (i.e. showleftmenu.php) which in turn is ONLY reading in a text file. This is what I don't understand...

Get straight to the point; simply include in the text file. So inside new.php:
PHP Code:

<?php
// DISABLE this...
//include("admin/showleftmenu.php");

// replace that with
require_once( './admin/lmenu.txt' );

// the rest of your code...
?>


If that idea doesn't suit you, then the reason you might be getting that "warning" message is cause your path is wrong... inside showleftmenu.php:

PHP Code:

// php script used to display content of text file
// use an absolute path for this file since this INCLUDE file is possibly included from anywhere?
$leftMenu = "/home/dopee/public_html/admin/lmenu.txt";
$lfilePointer = fopen($leftMenu, "r+");
while (!feof($lfilePointer))
{
             $line = fgets($lfilePointer, 4096);
             print $line;
}
fclose($lfilePointer); 



.. utltimately you can control the include folder in php.ini but this is something you probably want to do at a later stage.
  #3  
Old 06-May-2004, 12:03
dopee dopee is offline
Awaiting Email Confirmation
 
Join Date: Feb 2004
Location: south africa
Posts: 109
dopee will become famous soon enough
hey jds thanx for the reply.

Yes I understand now...I added

$leftMenu = "lmenu.txt";
$lfilePointer = fopen($leftMenu, "r+");
while (!feof($lfilePointer))
{
$line = fgets($lfilePointer, 4096);
print $line;
}
fclose($lfilePointer);

?>
to my new.php file and it works fine now.

But now I have another ques:
In this code:
<?php
require_once( './admin/lmenu.txt' );
?>

Is this better code to use instead of opening,reading, and closing the text file?
  #4  
Old 07-May-2004, 05:27
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
I would GUESS so but to be honest I haven't really made any tests to see if that is indeed true. However, just counting the functions required to open, read (,print/echo) and close a file rather than just include it sounds a lot more complicated to me.
 
 

Recent GIDBlogProblems with the Navy (Chiefs) by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Remote access to XP Prof op. system lizard- Computer Hardware Forum 10 18-May-2005 07:44
access local webserver from the local host calisro Apache Web Server Forum 1 10-May-2004 09:53
Urgernt: Extremely queer Apache access log moothecow Apache Web Server Forum 1 20-Dec-2003 03:45
FREE 25 MB, No Ads, Control Panel, ASP, ColdFusion, PHP, MySQL, Access Hosting rkmails Free Web Hosting 0 08-Sep-2003 06:49
Access 2000 pcxgamer Web Design Forum 6 23-May-2003 07:29

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 00:26.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.