Help - Search - Member List - Calendar
Full Version: fopen problem
WorkTheWeb Forums > Webmaster Resources > PHP Help
Support our Sponsors!
Ron Eggler @ work
hi,

I got following function to check if a specific string already exist in a
specific file but it doesn't work.
I not even see the string: "valid file-pointer" but I don't know why. May
anyone help me please?
Thank you!

function string_exists($email)
{
$file=fopen ($blacklist,"r");
if ($file)
{
echo "valid file-pointer";
while(!feof($file))
{
$buffer = fgets($file,4096);
echo $buffer."<br>n";
if ($buffer==$email)
{
echo "already string exists!<br>n";
return true;
}
else
{
echo "not yet!<br>n";
}
}
return false;
}
}

Steve
QUOTE
I not even see the string: "valid file-pointer" but I don't know why.

error_reporting(E_ALL);

---
Steve

Kimmo Laine
"Ron Eggler @ work" <[Email Removed]> wrote in message
news:[Email Removed]...
QUOTE
hi,

I got following function to check if a specific string already exist in a
specific file but it doesn't work.
I not even see the string: "valid file-pointer" but I don't know why. May
anyone help me please?
Thank you!

function string_exists($email)
{
$file=fopen ($blacklist,"r");

$blacklist has not been defined, or it is outside the variablescope. I'm
guessing you've defined $blacklist elsewhere in the code. The easiest thing
to do is define $blacklist global. Just insert the line

global $blacklist;

at the first line of the funtion, before $file=fopen(.... That way the
function "sees" the variable as well, and therefore knows what to open.

Didn't check the rest of the code. Try with that and tell us what happens.

--
Welcome to Usenet! Please leave tolerance, understanding
and intelligence at the door. They aren't welcome here.
eternal piste erection miuku gmail piste com

Ron Eggler @ work
Kimmo Laine wrote:
QUOTE
"Ron Eggler @ work" <[Email Removed]> wrote in message
news:[Email Removed]...
$blacklist has not been defined, or it is outside the variablescope.
I'm guessing you've defined $blacklist elsewhere in the code. The
easiest thing to do is define $blacklist global. Just insert the line

global $blacklist;

at the first line of the funtion, before $file=fopen(....  That way
the function "sees" the variable as well, and therefore knows what to
open.

Didn't check the rest of the code. Try with that and tell us what
happens.

yup, thanks very much. that's it :)


PHP Help | Linux Help | Web Hosting | Reseller Hosting | SSL Hosting
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2006 Invision Power Services, Inc.