PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
GeXus
Forum Regular
Posts: 631 Joined: Sat Mar 11, 2006 8:59 am
Post
by GeXus » Fri Aug 18, 2006 9:34 pm
Code: Select all
<?
class Validation{
function isNotEmpty($f){
if (strlen($f < 0))
return (false);
else
return (true);
}
}
?>
Code: Select all
if ($validate->isNotEmpty($_POST['username']))
{
$smarty->assign('validationError', 'Please create a username below');
}
Is there something wrong with this? No matter what it always returns false...
anjanesh
DevNet Resident
Posts: 1679 Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India
Post
by anjanesh » Fri Aug 18, 2006 9:48 pm
Whats the value of username before the validation check ? echo $_POST['username'];
GeXus
Forum Regular
Posts: 631 Joined: Sat Mar 11, 2006 8:59 am
Post
by GeXus » Fri Aug 18, 2006 9:51 pm
anjanesh wrote: Whats the value of username before the validation check ? echo $_POST['username'];
The value is there, its 'asdfasdf' which is what I happen to have entered. Also if I just do
Code: Select all
if(strlen($_POST['username'] < 0))
{
echo "validation";
}
that works fine... so i think it's something with the class... I do have other functions within that class that are working just fine however.
Jenk
DevNet Master
Posts: 3587 Joined: Mon Sep 19, 2005 6:24 am
Location: London
Post
by Jenk » Fri Aug 18, 2006 9:54 pm
you do realise you are checking the length of a boolean, right?
have a closer look..
should be:
or for semantics sake:
Code: Select all
if (strlen($f) < 1) {
return false;
}
GeXus
Forum Regular
Posts: 631 Joined: Sat Mar 11, 2006 8:59 am
Post
by GeXus » Fri Aug 18, 2006 9:57 pm
Jenk wrote: you do realise you are checking the length of a boolean, right?
have a closer look..
should be:
or for semantics sake:
Code: Select all
if (strlen($f) < 1) {
return false;
}
Jenk.. Doh! I just realized that.... thanks!
GeXus
Forum Regular
Posts: 631 Joined: Sat Mar 11, 2006 8:59 am
Post
by GeXus » Fri Aug 18, 2006 11:47 pm