Page 1 of 1

Block contained text in a field?

Posted: Wed Mar 22, 2006 9:58 pm
by Citizen
Is there a way to do this?

Code: Select all

if ($variable contains "textstring"){
echo "invalid text";
}
So that if the $variable was hellotextstringworld, it wouldnt work.

Posted: Wed Mar 22, 2006 10:00 pm
by hawleyjr

Posted: Wed Mar 22, 2006 10:08 pm
by Citizen
Thanks!

Posted: Wed Mar 22, 2006 10:48 pm
by Citizen
I got it to work for one of my fields, but this one doesnt seem to be working:

Code: Select all

$findme2 = 'visitshark';
$pos2 = strpos($website, $findme2);
if ($pos2 === true) {
echo "Links containing VisitShark are not permitted for security reasons. Please enter a valid website address.";
}
Any ideas why this one isnt working? Do I have to change the === if i'm checking for "true" instead of "false"?

Posted: Wed Mar 22, 2006 10:59 pm
by hawleyjr
Citizen wrote:I got it to work for one of my fields, but this one doesnt seem to be working:

Code: Select all

$findme2 = 'visitshark';
$pos2 = strpos($website, $findme2);
if ($pos2 === true) {
echo "Links containing VisitShark are not permitted for security reasons. Please enter a valid website address.";
}
Any ideas why this one isnt working? Do I have to change the === if i'm checking for "true" instead of "false"?
This function may return Boolean FALSE, but may also return a non-Boolean value which evaluates to FALSE, such as 0 or "". Please read the section on Booleans for more information. Use the === operator for testing the return value of this function.
Check for False not true

Posted: Thu Mar 23, 2006 12:24 am
by Citizen
Thanks, I ended up doing a (!($pos === false)) :)

Posted: Thu Mar 23, 2006 12:27 am
by feyd
ahem:

$pos !== false

Posted: Thu Mar 23, 2006 12:38 am
by Citizen
feyd wrote:ahem:

$pos !== false
Doh! Thanks feyd!