Reputation: 73
I'm writing the php code which linked with database.
If I put the value on the php code for example
$pid = somevalue.
this some value will pass it to the next php file.
and I want to check this somevalue is not empty or not a string value
if( some condition ){
printf("Invalid input: %s\n", mysqli_connect_error());
echo "<br/><a href='index.php'>Back to previous page</a>";
exit();
}
Upvotes: 2
Views: 142
Reputation: 7659
if(!empty($pid) and !is_string($foo)){
printf("Invalid input: %s\n", mysqli_connect_error());
echo "<br/><a href='index.php'>Back to previous page</a>";
exit();
}
Upvotes: 0
Reputation: 528
Just define it as spoken
if ( ! empty($foo) && ! is_string($foo) ) {
}
Upvotes: 0
Reputation: 138
use
if (!empty($pid) && is_numeric($pid)) {
// proceed
} else {
// error
}
Upvotes: 1