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

エラーメッセージ

目次一覧

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

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


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


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

 閲覧数:236 投稿日: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 / 原因判明

 閲覧数:213 投稿日: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

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



週間人気ページランキング / 11-20 → 11-26
順位 ページタイトル抜粋 アクセス数
1 ブラウザを閉じたらセッションデータはどうなるの? | セッション 9
2 PHP用語 4
2 Parse error: syntax error, unexpected 'public' (T_PUBLIC) | Parse error(エラーメッセージ) 4
3 「POSIX正規表現」と「PCRE正規表現」の違い 3
3 セッション名 | セッション 3
3 PHPで定数を定義する方法は2種類ある / 配列定数の定義 3
3 No route found fo | エラーメッセージ 3
3 Warning: strlen() expects parameter 1 to be string, array given in ○○.php on line △△ | Warning(エラーメッセージ) 3
4 ( ! ) Fatal error: Uncaught PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'カラム名' cannot be null | Fatal error(エラーメッセージ) 2
4 spliceImageメソッド | Imagickクラス 2
4 Fatal error: Uncaught HeadlessChromium\Exception\OperationTimedOut: Operation timed out (3sec) in | Fatal error(エラーメッセージ) 2
4 Fatal error: require_once(): Failed opening required 'PEAR.php' | Fatal error(エラーメッセージ) 2
4 位置を表現するメタキャラクタ(アンカー) 2
4 ( ! ) Fatal error: Uncaught Abraham\TwitterOAuth\TwitterOAuthException | Fatal error(エラーメッセージ) 2
4 curl で Cookie を使用する 2
4 http_build_queryとは? / 構文 /パラメータ 2
4 セッション単位 | セッション 2
4 Warning: Division by zero | Warning(エラーメッセージ) 2
4 正規表現 | テキスト処理 2
4 Column not found: 1054 Unknown column | Fatal error(エラーメッセージ) 2
2025/11/27 1:02 更新