0

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

3
Contributors
9
Replies
10
Views
5 Years
Discussion Span
Last Post by whojstall11
0

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

0

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);
     }
?>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.