「include_once」で「An error occurred.」と表示される場合の原因は、大きく分けると 2 種類あります。

エラーメッセージ

目次一覧

 状態:-  閲覧数:824  投稿日:2023-02-28  更新日:2023-02-28  
このエントリーの結論 / 遭遇事例 / エラーが発生したコード

修正失敗コード1 / 修正失敗コード2 / 原因判明


ファイルが存在するかどうか調べてからinclude_onceを実行します。


このエントリーの結論 / 遭遇事例 / エラーが発生したコード

 閲覧数:241 投稿日:2023-02-28 更新日:2023-02-28 

このエントリーの結論


「include_once」で「An error occurred.」と表示される場合の原因は、大きく分けると 2 種類あります。
A.「include_once」で指定したファイルパスが誤っている場合
B.「include_once」で指定したファイル先の内容にエラーがある場合

遭遇事例


エラーメッセージ
An error occurred.
Sorry, the page you are looking for is currently unavailable.
Please try again later.

If you are the system administrator of this resource then you should check the error log for details.

Faithfully yours, nginx.

エラーが発生したコード


include_once(dirname(__FILE__).'/../include/controller-footerdata.php');


修正失敗コード1 / 修正失敗コード2 / 原因判明

 閲覧数:218 投稿日:2023-02-28 更新日:2023-02-28 

修正失敗コード1


パスがおかしいのだろうと思い直書きするも、「An error occurred.」
include_once('/var/www/html/1-p35/0webapp/include/controller-footerdata.php');


修正失敗コード2


パスが存在した場合のみinclude_once実行するよう修正するも、「An error occurred.」
$file1 = dirname(__FILE__) . '/../include/controller-footerdata.php';
if (file_exists($file1)) {
 include_once($file1);
}

$file2 = '/var/www/html/1-p35/0webapp/include/controller-footerdata.php';
if (file_exists($file2)) {
 include_once($file2);
}


原因判明


「include_once」で指定したファイル先の内容にエラーがあった
いずれのパス記述も正しかった。
「include_once」で指定したファイル先の内容にエラーがあった。


[error] 23449#23449: *63 FastCGI sent in stderr: "PHP message: PHP Parse error: syntax error, unexpected 'ini_set' (T_STRING)

Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

コメント投稿(ログインが必要)



週間人気ページランキング / 12-10 → 12-16
順位 ページタイトル抜粋 アクセス数
1 ブラウザを閉じたらセッションデータはどうなるの? | セッション 5
2 PHPで定数を定義する方法は2種類ある / 配列定数の定義 3
3 PHP用語 2
3 Fatal error(エラーメッセージ) カテゴリー 2
3 mixed | 型 2
3 ブラウザを閉じたらセッションデータはどうなるの? | セッション 2
3 Warning: session_write_close(): Failed to write session data (user) | Warning(エラーメッセージ) 2
3 セッション管理が必要な理由は、HTTPプロトコルには状態を保持する機能がないため | セッション 2
3 http_build_query | URLs(関数) 2
3 session.gc_maxlifetime | セッション 2
3 リソース型 | 型 2
3 型キャスト | 型 2
4 バッファリング | 出力バッファリング制御(関数) 1
4 Composer経由でインストール / Composer経由でインストールした後の使い方 / Composer経由でインストールした後、後日現状確認 1
4 foreach文 | 制御構造 1
4 blurImageメソッド | Imagickクラス 1
4 Catchable fatal error: Object of class DateTime could not be converted to string | Fatal error(エラーメッセージ) 1
4 creating database ERROR!!: exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 1 table tally already exists' | SQLite(エラーメッセージ) 1
4 クロージャ(関数) カテゴリー 1
4 Sorry, that page does not exist. | Twitter API(エラーメッセージ) 1
2025/12/17 1:02 更新