-7

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';
?>
  • if checking an integer (as is the case in `strlen`) even in PHP, don't check `int` values against their `string` equivalents, technically this is a logic error as `"32"` is checking for the string value of '32' and NOT the integer value of 32 – txtechhelp Dec 17 '13 at 08:58

3 Answers3

4

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

try that out

txtechhelp
  • 6,625
  • 1
  • 30
  • 39
0

What about

if($len != 32 and $len != 40)
Maarkoize
  • 2,601
  • 2
  • 16
  • 34
0
<?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';
?>
krutssss
  • 934
  • 1
  • 10
  • 23