Question

I have this code, i want it to check if the length is NOT 32 or 40. The code below only checks if the word is 32 or 40 in length.

<?
$name = mysql_real_escape_string($_POST['dgt']);
$len = strlen($name);
if (!($len == "32" or $len == "40")){
print "This is not a name.";
} else {
echo 'This is a name';
?>
Was it helpful?

Solution

if ($len != 32 && $len != 40)

try that out

OTHER TIPS

What about

if($len != 32 and $len != 40)
<?php
$name = mysql_real_escape_string($_POST['dgt']);
$len = strlen($name);
if ($len != 32 && $len != 40){
print "This is not a name.";
} else {
echo 'This is a name';
?>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top