我閱讀了有關此標題的主題,但無法使其適用於我的程序。我之前刪除了html和空格,但仍然看不到有什麼問題。 connect.php文件的目的是連接到數據庫,我使用app_config.php文件從connect.php調用handle_error函數來打印嘗試連接到數據庫時發生的任何錯誤。非常感謝您的幫助!無法修改標題信息 - 已由
錯誤是:
警告:不能更改頭信息 - 頭已經發出在/ home3(輸出開始/home3/alfredbiz/public_html/phpMM/ch05/scripts/connect.php:1) /alfredbiz/public_html/phpMM/ch05/app_config.php第12行
這裏是connect.php
<?php
//appel le fichier de mot de passe
require_once '/home3/alfredbiz/public_html/phpMM/ch05/app_config.php';
require_once '/home3/alfredbiz/public_html/phpMM/ch05/app_connexion.php';
//database connexion
$link = mysqli_connect(DATABASE_HOST, DATABASE_USERNAME, DATABASE_PASSWORD, DATABASE_NAME);
// check connection
if (!$link) {
$user_error_message = "there was a problem connecting to the database that holds the information we need to get you connected.";
$system_error_message = mysqli_connect_error();
handle_error($user_error_message, $system_error_message);
}
//editer les tables avec controle d erreur
$result = mysqli_query($link, "show tables");
if(!$result){
die("<p>Error in Listing tables: " .mysql_error() . "</p>");
}
echo "<p> requette executee avec success</p>";
?>
app_config.php
<?php
//set up debug mode
define("DEBUG_MODE", true);
function debug_print($message) {
if(DEBUG_MODE) {
echo $message;
}
}
function handle_error($user_error_message, $system_error_message) {
header("location: /home3/alfredbiz/public_html/phpMM/ch05/scripts/show_error.php?" ."error_message={$user_error_message}&" ."system_error_message= {$system_error_message}");
exit();
}
?>
看看你的輸出。該錯誤消息之前可能有一行。 – aynber
發佈配置以及。'ob_start();'通常情況下訣竅 –