Re: Re: Opening a file

From: Date: Fri, 07 Sep 2007 01:48:38 +0000
Subject: Re: Re: Opening a file
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-261808@lists.php.net to get a copy of this message
On Wed, 2007-09-05 at 10:29 -0400, Dan Shirah wrote: > Correction, I am now getting this error: > > PHP Warning: file(fruits.txt) > > [function.file<http://develop1/credit%20card%20processing/function.file>]: > failed to open stream: No such file or directory > PHP Warning: in_array() > > [function.in-array<http://develop1/credit%20card%20processing/function.in-array>]: > Wrong datatype for second argument > > But the file IS in the same folder. does ls -l give you the answer? (Does your web server has permission to read the file?) bye Ronald > > > On 9/5/07, Dan Shirah <mrsquash2@gmail.com> wrote: > > > > Good Morning! > > > > Opening this file is proving to be a pain. I have a folder that contains a > > PHP page and a text file. I am trying to open the contents of the txt file > > using file() but it keeps erroring out. Below is the code I'm using to try > > and open it: > > > > <?php > > $fruit = "apple"); > > $lines = file("fruits.txt"); > > if (in_array($fruit,$lines)) > > { > > $a = "Y"; > > } > > ?> > > > > So, I'm setting my variable, opening my file as an array in $lines, then > > checking to see if my variable is in the array, and if it is, assign a value > > ot a new variable. However, I am getting the following error: > > > > PHP Warning: in_array() > > [function.in-array<http://develop1/credit%20card%20processing/function.in-array>]: > > Wrong datatype for second argument > > > > Any ideas? > >

« previous php.general (#261808) next »