Ron Eggler @ work
Jun 14 2005, 06:58 AM
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
Jun 14 2005, 07:48 AM
QUOTE |
I not even see the string: "valid file-pointer" but I don't know why.
|
error_reporting(E_ALL);
---
Steve
Kimmo Laine
Jun 14 2005, 08:03 AM
"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
Jun 14 2005, 08:43 AM
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 :)
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.