Last active
March 14, 2018 06:17
-
-
Save ryu1-1uyr/89c4c7d3b1f7326bd3ed5a60ad14f1c4 to your computer and use it in GitHub Desktop.
接続テスト
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>cotemttest</title> | |
| </head> | |
| <body> | |
| <div> | |
| <?php | |
| $user = 'ryu'; | |
| $password = 'ryuryu1207'; | |
| $dbname = 'slimapp'; | |
| $host = '127.0.0.1:3306'; | |
| $dsn = "mysql:host={$host};dbname={$dbname};charset=utf8"; | |
| //$mysqli = new mysqli($host,$user,$password,$dbname); | |
| try{ | |
| $pdo = new PDO($dsn,$user,$password); | |
| $pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES,false); | |
| $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | |
| echo "DB{$dbname} 接続しました"; | |
| $pdo = null; | |
| } catch (Exception $e){ | |
| echo 'エラーです'; | |
| echo $e->getMessage(); | |
| exit(); | |
| } | |
| ?> | |
| </div> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment