このヘッダーについてのトピックを読みましたが、プログラムでは機能しませんでした。私は前にhtmlとスペースを削除しましたが、何が間違っているかはまだ分かりません。 connect.phpファイルの目的はデータベースに接続することで、app_config.phpファイルを使用してconnect.phpからhandle_error関数を呼び出し、データベースへの接続中に発生したエラーを表示します。あなたの助けに感謝します!ヘッダー情報を変更できません - 既に送信されたヘッダー
エラーは次のとおりです。
警告:ヘッダー情報を変更することはできません - すでに(出力が/home3/alfredbiz/public_html/phpMM/ch05/scripts/connect.php:1で開始)で/ HOME3によって送られたヘッダラインここ12
上/alfredbiz/public_html/phpMM/ch05/app_config.phpは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();'通常はこのトリックを行う –