Im trying to write an else statement in php where: if keyword is equal to letter or word it will give me an error message. right now my statement looks like this.

mysqli_stmt_close ($query);
            } else //problem with a query
              echo "Error: " . mysqli_error($conn);
          } else { //no keyword 
              echo "No keyword was specified";
          }else (keyword == "??") {
              echo "has to be a number";
          }
      
         mysqli_close($conn);
     }
?>
  </body>
</html>

Keyword is an int

Try this:

if (is_numeric($val)) {
    echo '$val';

  }else{
  echo 'not an integer";
}

Perfect thank you!!!!!!!!!!

one more thing it work but when i make another else statement:

if (is_numeric($keyword)) {
              echo "Here are your results";
            }[B]elseif($keyword == null){
           echo "have to enter something";[/B]
           }else{
           echo "$keyword not an number";
           }
         
         
         mysqli_close($conn);
     }
?>
  </body>
</html>

it gives me two errors
Notice: Undefined variable: keyword in E:\xampp\htdocs\m9\findRecords2.php on line 39

Notice: Undefined variable: keyword in E:\xampp\htdocs\m9\findRecords2.php on line 41
have to enter something

replace null with empty quote,

I would personally check if its empty first, then check if its an int.

if (is_numeric($keyword)) {
              echo "Here are your results";
            }elseif($keyword == ""){
           echo "have to enter something";
           }else{
           echo "$keyword not an number";
           }
         
         
         mysqli_close($conn);
     }
?>

change elseif line to:

elseif(!isset($keyword)) {

I tried isnull() already it didnt work

else if*

add space between else and if

that worked!!!!!!!! so what does isnull() do then? thank you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.