0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

PHPのデータベース接続方法

Posted at
PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, ] ); /* データベースから値を取ってきたり, データを挿入したりする処理 */ } catch (PDOException $e) { // エラーが発生した場合は「500 Internal Server Error」でテキストとして表示して終了する // - もし手抜きしたくない場合は普通にHTMLの表示を継続する // - ここではエラー内容を表示しているが, 実際の商用環境ではログファイルに記録して, Webブラウザには出さないほうが望ましい header('Content-Type: text/plain; charset=UTF-8', true, 500); exit($e->getMessage()); } // Webブラウザにこれから表示するものがUTF-8で書かれたHTMLであることを伝えるため header('Content-Type: text/html; charset=utf-8'); ?> Example
</body>
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?