I had some problematic code in which a conditional check for die killed the rest of the script. What's the best approach to see if something actually does die, so I can implement some alerts? The manual doesn't seem to mention this.
The resulting code would have the following logic:
1. $sql = insert statement
2. mysql_query($sql) or die ("Failed");
3. $errmsg = "Failed query";
4. if die = true, then fwrite to log, else fwrite $sql to log
However, die always seems to evaluate as true.
The code in question:
$sql = "INSERT INTO $imagesTable ($imageFields) VALUES('NULL', '$name', '$path', '$type', '$size');";
mysql_query($sql) or die("Failed Query of " . $sql);
if (die) {
$msg = "Insert failed: " . $sql . "\n";
if(file_exists($logdir)) {
fwrite($output, $msg);
}
} else {
$msg = $sql . "\n";
if(file_exists($logdir)) {
fwrite($output, $msg);
}
}