Re: Script under Windows OK, under Linux, not...

From: Date: Sat, 25 Jan 2003 21:29:50 +0000
Subject: Re: Script under Windows OK, under Linux, not...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-133127@lists.php.net to get a copy of this message
Why are you opening the file in append mode? As the manual says: " a+' - Open for reading and writing; place the file pointer at the end of the file." Try using 'r+' instead or rewind the file pointer before reading. Danny. ----- Original Message ----- From: "Daniel Page" <dlp@dlpage.com> To: <php-general@lists.php.net> Sent: Saturday, January 25, 2003 11:39 AM Subject: [PHP] Script under Windows OK, under Linux, not... > Hi, > > I have the following code : > > $_fp = fopen("/home/dh2240/mgt/index.php", "a+") or die(); > $_contents = fread($_fp,filesize("/home/dh2240/mgt/index.php")); > fclose ($_fp); > //Menu elements > $_sme = strpos("$_contents","sub_menu_elements"); > echo "sme = $_sme<p>"; > ... > > It should display somthing like "sme = 850", after finding the string in the > specified file. > > Under windows, this script works fine (except replacing the > "/home/dh2240/mgt/index.php" by "c:/apache/htdocs/mgt/index.php")... it > seems that the file index.php cannot be opened under linux... > The file is chmod 777, along with the directory /mgt, and the files > identical, but still no luck... The fopen does not die(), but it does not > seem to read any data from the file... I'm confused, and not sure how to > check what is happening... Anyone got any ideas ? > > Cheers, > Daniel > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#133127) next »