LoginSignup
0
0

More than 1 year has passed since last update.

PHP データベースに接続

Posted at

 Mac MAMP データベースに接続

PDO = PHP Data Object
try = エラーの場合に動作し内容の確認ができる
----------------------------------------------------------------------
例  
<?php
  try {
    $db = new PDO('mysql:dbname=データベース名;host=localhost;port=8889;charset=utf8','root','root');
  } catch(PDOException $e){
    echo 'DB接続エラー:'.$e->getMessage();
  }
?>

エラーの内容を確認を行うには

下記を記述することでエラーの中身を確認可能!!!

var_dump($要素->errorInfo());
exit();
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