了什麼happenned是你的“CREATE TABLE”将失敗。
擷取到對于每一個MySQL的查詢後,檢查錯誤(在你的代碼)的習慣:有一些時候,你可以忽略錯誤,但它是罕見的。是以程式alonghte線:
Create query: $sql =
Set parameters: $aParams = (or bind paramters)
Execute query
If errors
If debug: Show error and query
If live: Log error and query
我不會放棄的解決方案是代碼,如一個問題,你按照教程是它使用mysql_(),它們将在短期内貶值的功能。您應該使用PDO (PHP Database Objects)或mysqli()函數,否則您的代碼将無法在幾個釋出時間内運作。
使用PDO,您可以設定錯誤處理以使用異常,并且您可以将每個調用都包裝在try {} catch {}中,這使捕捉和報告錯誤的習慣變得非常容易。
$sql = 'CREATE TABLE....';
$aParams = array(
':param_name' => $param_value,
':param_name2' => $param_value2
);
try {
$stmnt = $db->prepare($sql);
$stmnt->execute($aParams);
$stmnt = null;
} catch (Exception $e) {
// Error log here; $e contins line of error and the actual error, you have $sql and $aParams
LogDBError($e, $sql, $aParams);
}