note 23790 deleted from function.system by dams
| From: | dams@php.net | Date: | Tue, 30 Jul 2002 00:28:42 +0000 |
| Subject: | note 23790 deleted from function.system by dams | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-33911@lists.php.net to get a copy of this message | ||
Assuming that 0 = false and 1 = true doesn't always work.
If you are having problems trying to figure out why the system() function sometimes seems to return
true/false backwards, you should verify the return codes of the system command you are executing.
For example:
<?
$cmd="/usr/bin/mysql -h$host -u$user -p$pass -e'$command'";
$res = (system($cmd)) ? true : false;
print $res;
?>
// if the command fails, 1 will be printed.
// if the command works, 0 will be printed.
<?
if(system($cmd) === false) {
print "Failed";
} else {
print "Success";
}
?>
// outputs Success when it fails
This is due to mysql returning 0 if no errors have occurred
and returning 1 if errors have occurred.
Might be good to look up returned error codes of the system command you are executing to make sure
you are branching correctly.