[PHP] Script under Windows OK, under Linux, not...

2003-01-25 Thread Daniel Page
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 = $_smep;
...

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




Re: [PHP] Script under Windows OK, under Linux, not...

2003-01-25 Thread Danny Shepherd
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 [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
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 = $_smep;
 ...

 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



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php