我正在使用以下代码。当查询崩溃时,它不会显示我在“catch”块中定义的ALERT。为什么PHP不显示异常?
<?php
error_reporting(E_ALL^E_NOTICE);
require_once("../Lib/dbaccess.php");
//Retrieve values from Input Form
$CategoryName = $_POST["inCategory"];
$TotalMembers = $_POST["inTotalMembers"];
$Details = $_POST["inDetails"];
$CategoryName = $_POST["inCategory"];
$Chairman = $_POST["inChairman"];
$InsertQuery = "REPLACE INTO electioncategorymaster (ecname, ecdescription, ectotalmembers, ecchairman, lastupdated) VALUES ('".$CategoryName."','".$Details."',".$TotalMembers.",'".$Chairman."',now())";
try
{
$Result = dbaccess::InsertRecord($InsertQuery);
}
catch(exception $ex)
{
echo "<script type='text/javascript'>alert('".$ex."');</script>";
}
?>
你确定有抛出的异常吗? – 2010-01-09 10:30:33
有时我注意到SQL查询因语法错误或其他原因失败,但没有显示异常。 – RKh 2010-01-09 11:45:09