質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
PHP

PHPは、Webサイト構築に特化して開発されたプログラミング言語です。大きな特徴のひとつは、HTMLに直接プログラムを埋め込むことができるという点です。PHPを用いることで、HTMLを動的コンテンツとして出力できます。HTMLがそのままブラウザに表示されるのに対し、PHPプログラムはサーバ側で実行された結果がブラウザに表示されるため、PHPスクリプトは「サーバサイドスクリプト」と呼ばれています。

Q&A

解決済

2回答

1425閲覧

$pwdhttps://localhost\これからはじめる人のPHP学習帖\Chapter5は正常に実行出来て、...\Chapter5\img_dbで「サーバー接続に失敗!」となります。

退会済みユーザー

退会済みユーザー

総合スコア0

PHP

PHPは、Webサイト構築に特化して開発されたプログラミング言語です。大きな特徴のひとつは、HTMLに直接プログラムを埋め込むことができるという点です。PHPを用いることで、HTMLを動的コンテンツとして出力できます。HTMLがそのままブラウザに表示されるのに対し、PHPプログラムはサーバ側で実行された結果がブラウザに表示されるため、PHPスクリプトは「サーバサイドスクリプト」と呼ばれています。

0グッド

0クリップ

投稿2021/01/09 07:42

編集2021/01/10 00:56

PHPの参考書で勉強しています。
「Chapter 5 画像管理プログラムをつくってみよう」に来ています。

URL https://localhost\これからはじめる人のPHP学習帖\Chapter5
は実行できるのですが、
https://localhost\これからはじめる人のPHP学習帖\Chapter5\img_db
を実行すると「サーバーに接続できません!」という表示が出ます。
https://localhost\これからはじめる人のPHP学習帖\Chapter4\4-4\18.php
は正常に実行することができます。

エラー内容を見てもよくわからないのでどこが悪いのか教えてください。
欠けている情報がありましたらお知らせください。
お願いいたします。

<?php // --------------------------------------- // データベースの環境変数 // --------------------------------------- $usr = 'root'; // ユーザー名(USBWebserverの場合) $pwd = 'usbw'; // パスワード(USBWebserverの場合) $host = 'localhost'; // データベース・ホスト名 $dbName = 'test'; // データベース名 $tblName = 'gallery'; // テーブル名 // --------------------------------------- // 画像管理プログラム用のテーブル定義 // --------------------------------------- $tableDef = array( 'title' => 'VARCHAR(20)', // タイトル 'name' => 'VARCHAR(50)', // 元のファイル名 'size' => 'INT', // ファイルサイズ 'height' => 'INT', // 高さ 'width' => 'INT', // 幅 'word' => 'VARCHAR(50)', // キーワード 'radio' => 'INT', // ラジオボタン 'checkbox' => 'VARCHAR(20)', // チェックボックス 'date' => 'DATETIME', // 登録日時 'image' => 'MEDIUMBLOB' // 画像ファイル ); /* 実行結果 http://localhost/C:\xampp\htdocs\これからはじめる人のPHP学習帖 \Chapter5a\img-db/createThum.php で以下が表示される。 */ ?> コード

mysql_error.log

1....後半 22021-01-09 14:49:14 0 [Note] C:\xampp\mysql\bin\mysqld.exe (initiated by: unknown): Normal shutdown 32021-01-09 14:49:14 0 [Note] Event Scheduler: Purging the queue. 0 events 42021-01-09 14:49:14 0 [Note] InnoDB: FTS optimize thread exiting. 52021-01-09 14:49:14 0 [Note] InnoDB: Starting shutdown... 62021-01-09 14:49:14 0 [Note] InnoDB: Dumping buffer pool(s) to C:\XAMPP\mysql\data\ib_buffer_pool 72021-01-09 14:49:14 0 [Note] InnoDB: Instance 0, restricted to 250 pages due to innodb_buf_pool_dump_pct=25 82021-01-09 14:49:14 0 [Note] InnoDB: Buffer pool(s) dump completed at 210109 14:49:14 92021-01-09 14:49:15 0 [Note] InnoDB: Shutdown completed; log sequence number 1049358; transaction id 2589 102021-01-09 14:49:15 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1" 112021-01-09 14:49:15 0 [Note] C:\xampp\mysql\bin\mysqld.exe: Shutdown complete 12 13InnoDB: using atomic writes. 142021-01-09 14:49:20 0 [Note] InnoDB: Mutexes and rw_locks use Windows interlocked functions 152021-01-09 14:49:20 0 [Note] InnoDB: Uses event mutexes 162021-01-09 14:49:20 0 [Note] InnoDB: Compressed tables use zlib 1.2.11 172021-01-09 14:49:20 0 [Note] InnoDB: Number of pools: 1 182021-01-09 14:49:20 0 [Note] InnoDB: Using SSE2 crc32 instructions 192021-01-09 14:49:20 0 [Note] InnoDB: Initializing buffer pool, total size = 16M, instances = 1, chunk size = 16M 202021-01-09 14:49:20 0 [Note] InnoDB: Completed initialization of buffer pool 212021-01-09 14:49:20 0 [Note] InnoDB: 128 out of 128 rollback segments are active. 222021-01-09 14:49:20 0 [Note] InnoDB: Creating shared tablespace for temporary tables 232021-01-09 14:49:20 0 [Note] InnoDB: Setting file 'C:\XAMPP\mysql\data\ibtmp1' size to 12 MB. Physically writing the file full; Please wait ... 242021-01-09 14:49:20 0 [Note] InnoDB: File 'C:\XAMPP\mysql\data\ibtmp1' size is now 12 MB. 252021-01-09 14:49:20 0 [Note] InnoDB: Waiting for purge to start 262021-01-09 14:49:20 0 [Note] InnoDB: 10.4.17 started; log sequence number 1049358; transaction id 2587 272021-01-09 14:49:20 0 [Note] InnoDB: Loading buffer pool(s) from C:\XAMPP\mysql\data\ib_buffer_pool 282021-01-09 14:49:20 0 [Note] Plugin 'FEEDBACK' is disabled. 292021-01-09 14:49:20 0 [Note] Server socket created on IP: '::'. 302021-01-09 14:49:20 0 [Note] Reading of all Master_info entries succeeded 312021-01-09 14:49:20 0 [Note] Added new Master_info '' to hash table 322021-01-09 14:49:20 0 [Note] C:\xampp\mysql\bin\mysqld.exe: ready for connections. 33Version: '10.4.17-MariaDB' socket: '' port: 3306 mariadb.org binary distribution 342021-01-09 14:49:20 0 [Note] InnoDB: Buffer pool(s) load completed at 210109 14:49:20 352021-01-09 14:49:58 8 [Warning] Access denied for user 'root'@'localhost' (using password: YES) 362021-01-09 14:50:01 9 [Warning] Access denied for user 'root'@'localhost' (using password: YES) 372021-01-09 14:53:42 12 [Warning] Access denied for user 'root'@'localhost' (using password: YES) 382021-01-09 15:07:39 13 [Warning] Access denied for user 'root'@'localhost' (using password: YES) 392021-01-09 15:07:43 14 [Warning] Access denied for user 'root'@'localhost' (using password: YES) 402021-01-09 15:26:23 16 [Warning] Access denied for user 'root'@'localhost' (using password: YES) 412021-01-09 15:33:27 17 [Warning] Access denied for user 'root'@'localhost' (using password: YES) 422021-01-09 15:54:37 19 [Warning] Access denied for user 'root'@'localhost' (using password: YES) 432021-01-09 16:10:32 20 [Warning] Access denied for user 'root'@'localhost' (using password: YES) 44

Apache error.log

1[Sat Jan 09 13:50:05.161264 2021] [php:error] [pid 7460:tid 1800] [client 127.0.0.1:52003] script 'C:/XAMPP/htdocs/\xe3\x81\x93\xe3\x82\x8c\xe3\x81\x8b\xe3\x82\x89\xe3\x81\xaf\xe3\x81\x98\xe3\x82\x81\xe3\x82\x8b\xe4\xba\xba\xe3\x81\xaePHP\xe5\xad\xa6\xe7\xbf\x92\xe5\xb8\x96/Chapter4/4-4/regist.php' not found or unable to stat 2[Sat Jan 09 13:51:31.020492 2021] [php:warn] [pid 7460:tid 1800] [client 127.0.0.1:52033] PHP Warning: require_once(env.php): Failed to open stream: No such file or directory in C:\XAMPP\htdocs\\xe3\x81\x93\xe3\x82\x8c\xe3\x81\x8b\xe3\x82\x89\xe3\x81\xaf\xe3\x81\x98\xe3\x82\x81\xe3\x82\x8b\xe4\xba\xba\xe3\x81\xaePHP\xe5\xad\xa6\xe7\xbf\x92\xe5\xb8\x96\Chapter4\4-6\regist.php on line 12 3[Sat Jan 09 13:51:31.020492 2021] [php:error] [pid 7460:tid 1800] [client 127.0.0.1:52033] PHP Fatal error: Uncaught Error: Failed opening required 'env.php' (include_path='C:\XAMPP\php\PEAR') in C:\XAMPP\htdocs\\xe3\x81\x93\xe3\x82\x8c\xe3\x81\x8b\xe3\x82\x89\xe3\x81\xaf\xe3\x81\x98\xe3\x82\x81\xe3\x82\x8b\xe4\xba\xba\xe3\x81\xaePHP\xe5\xad\xa6\xe7\xbf\x92\xe5\xb8\x96\Chapter4\4-6\regist.php:12\nStack trace:\n#0 {main}\n thrown in C:\XAMPP\htdocs\\xe3\x81\x93\xe3\x82\x8c\xe3\x81\x8b\xe3\x82\x89\xe3\x81\xaf\xe3\x81\x98\xe3\x82\x81\xe3\x82\x8b\xe4\xba\xba\xe3\x81\xaePHP\xe5\xad\xa6\xe7\xbf\x92\xe5\xb8\x96\Chapter4\4-6\regist.php on line 12 4[Sat Jan 09 14:24:35.959450 2021] [php:warn] [pid 7460:tid 1808] [client 127.0.0.1:53012] PHP Warning: Undefined variable $p in C:\XAMPP\htdocs\img_db\head.html on line 4 5[Sat Jan 09 14:24:35.959450 2021] [php:warn] [pid 7460:tid 1808] [client 127.0.0.1:53012] PHP Warning: Attempt to read property "title" on null in C:\XAMPP\htdocs\img_db\head.html on line 4 6[Sat Jan 09 14:24:35.959450 2021] [php:warn] [pid 7460:tid 1808] [client 127.0.0.1:53012] PHP Warning: Undefined variable $db in C:\XAMPP\htdocs\img_db\head.html on line 12 7[Sat Jan 09 14:24:35.959450 2021] [php:warn] [pid 7460:tid 1808] [client 127.0.0.1:53012] PHP Warning: Attempt to read property "error" on null in C:\XAMPP\htdocs\img_db\head.html on line 12 8[Sat Jan 09 14:24:35.959450 2021] [php:warn] [pid 7460:tid 1808] [client 127.0.0.1:53012] PHP Warning: Undefined variable $p in C:\XAMPP\htdocs\img_db\head.html on line 21 9[Sat Jan 09 14:24:35.959450 2021] [php:warn] [pid 7460:tid 1808] [client 127.0.0.1:53012] PHP Warning: Attempt to read property "menu" on null in C:\XAMPP\htdocs\img_db\head.html on line 21 10[Sat Jan 09 14:24:35.959450 2021] [php:warn] [pid 7460:tid 1808] [client 127.0.0.1:53012] PHP Warning: Undefined variable $p in C:\XAMPP\htdocs\img_db\head.html on line 24 11[Sat Jan 09 14:24:35.959450 2021] [php:warn] [pid 7460:tid 1808] [client 127.0.0.1:53012] PHP Warning: Attempt to read property "title" on null in C:\XAMPP\htdocs\img_db\head.html on line 24 12[Sat Jan 09 14:49:11.808822 2021] [mpm_winnt:notice] [pid 948:tid 616] AH00422: Parent: Received shutdown signal -- Shutting down the server. 13[Sat Jan 09 14:49:13.830949 2021] [mpm_winnt:notice] [pid 7460:tid 560] AH00364: Child: All worker threads have exited. 14[Sat Jan 09 14:49:15.277392 2021] [mpm_winnt:notice] [pid 948:tid 616] AH00430: Parent: Child process 7460 exited successfully. 15[Sat Jan 09 14:49:18.302853 2021] [ssl:warn] [pid 4304:tid 624] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name 16[Sat Jan 09 14:49:18.349862 2021] [ssl:warn] [pid 4304:tid 624] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name 17[Sat Jan 09 14:49:18.369859 2021] [mpm_winnt:notice] [pid 4304:tid 624] AH00455: Apache/2.4.46 (Win64) OpenSSL/1.1.1h PHP/8.0.0 configured -- resuming normal operations 18[Sat Jan 09 14:49:18.369859 2021] [mpm_winnt:notice] [pid 4304:tid 624] AH00456: Apache Lounge VS16 Server built: Oct 2 2020 11:45:39 19[Sat Jan 09 14:49:18.369859 2021] [core:notice] [pid 4304:tid 624] AH00094: Command line: 'C:\xampp\apache\bin\httpd.exe -d C:/XAMPP/apache' 20[Sat Jan 09 14:49:18.369859 2021] [mpm_winnt:notice] [pid 4304:tid 624] AH00418: Parent: Created child process 1828 21[Sat Jan 09 14:49:18.770275 2021] [ssl:warn] [pid 1828:tid 556] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name 22[Sat Jan 09 14:49:18.810276 2021] [ssl:warn] [pid 1828:tid 556] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name 23[Sat Jan 09 14:49:18.834446 2021] [mpm_winnt:notice] [pid 1828:tid 556] AH00354: Child: Starting 150 worker threads. 24[Sat Jan 09 15:38:00.741635 2021] [php:error] [pid 1828:tid 1816] [client 127.0.0.1:54915] script 'C:/XAMPP/htdocs/\xe3\x81\x93\xe3\x82\x8c\xe3\x81\x8b\xe3\x82\x89\xe3\x81\xaf\xe3\x81\x98\xe3\x82\x81\xe3\x82\x8b\xe4\xba\xba\xe3\x81\xaePHP\xe5\xad\xa6\xe7\xbf\x92\xe5\xb8\x96/Chapter4/4-6/19.php' not found or unable to stat 25

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答2

0

発売日:2013/11/13

古すぎます。
PHP7以上対応、可能ならここ1年以内のものにしてください。変な煽り文句がないものであることも必須条件。
XAMPPを古いものにして書籍のバージョンに合わせれば問題は減るでしょうけど、サポートされなくなったバージョンで覚えても何の役にも立ちません。

投稿2021/01/09 09:17

m.ts10806

総合スコア80850

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

退会済みユーザー

退会済みユーザー

2021/01/10 01:11

ご教授の通りですが、古い書き方などを今様に書き換えを勉強しながら、書き換えてここまで来たので、頑張ってこの章が最後なのでやり遂げたいと思います。がんこですみません。古いもので勉強するのもそれなりに勉強になっています。このあと新しい参考書でsymfonyも勉強しようと思っていますので、これからもよろしくお願いいたします。
m.ts10806

2021/01/10 02:02

サポートされなくなったバージョンで覚えても何の役にも立ちません。 「今ように書き換える」というのが非常に無駄な作業です。 機能だけ代替探したところで実装が古ければ同じ。
退会済みユーザー

退会済みユーザー

2021/01/17 05:15

やっと終わりましたのでsymfonyでなくLalavelを勉強しようと思っています。 ありがとうございました。
m.ts10806

2021/01/17 07:10

Laravel です。 特に報告しなくても良いかと思いますが、 Laravel も内部的にはSymfonyをエンジンとして使ってますし、 「きちんと規約通りに組む」ということを覚えるためにやっても良いかと思います。 それにLaravelは「Web職人のためのフレームワーク」なので、 PHPだけではなくWeb全般の知識技術が必要となります。 「書籍やり終えた→じゃあLaravelだ」とはならないんじゃないかなと。
guest

0

ベストアンサー

データベースの環境設定用ファイルChapter5/img_db/de_env.phpのコードをを見直しました。

ファイルChapter5までは接続できているのに、img_dbに接続できないのはなぜだろうと思い、参考書をよく読みなおして、データベースの環境設定用ファイルではないかと思い、de_env.phpの中の$pwd='usbw'
を$pwd='SQL6......'(自分のデータベース接続のパスワード)に変更して接続できました。

投稿2021/01/10 01:01

退会済みユーザー

退会済みユーザー

総合スコア0

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問