This file contains 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
<?php | |
$dsn = 'mysql:host=localhost;dbname=uriage;charset=utf8'; | |
$user = 'testuser'; | |
$password = 'testuser'; | |
// 例外処理 | |
try{ // 例外が発生するおそれがあるコード | |
// PDOクラスのオブジェクトを作成 | |
$dbh = new PDO($dsn, $user, $password); |
This file contains 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
<?php | |
// mysqliクラスのオブジェクトを作成 | |
$mysqli = new mysqli("localhost", "testuser", "testuser", "uriage"); | |
if ($mysqli->connect_error) { // connect_errorはPHP5.3.0以降で有効 | |
die("connect_error" . $mysqli->connect_error); | |
} | |
// 文字化け防止 | |
$mysqli->set_charset("utf8"); |
This file contains 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
<?php | |
// mysqliクラスのオブジェクトを作成 | |
$mysqli = new mysqli("localhost", "testuser", "testuser", "uriage"); | |
if ($mysqli->connect_error) { // connect_errorはPHP5.3.0以降で有効 | |
die("connect_error" . $mysqli->connect_error); | |
} | |
// 文字化け防止 | |
$mysqli->set_charset("utf8"); |
This file contains 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
<?php | |
function stmt_ex($stmt){ | |
// 結果変数をバインド | |
mysqli_stmt_bind_result($stmt, $id, $name); | |
// クエリを実行 | |
mysqli_stmt_execute($stmt); | |
// データの取得及び取得データの表示 | |
while (mysqli_stmt_fetch($stmt)) { | |
echo "id=" . $id; |
This file contains 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
<?php | |
// MySQLへ接続及びデータベースの選択 | |
$link = mysqli_connect("localhost", "testuser", "testuser", "uriage"); | |
if(mysqli_connect_errno() > 0){ | |
die("接続失敗" . mysqli_connect_error()); | |
} | |
// 文字化け防止 | |
mysqli_set_charset($link, "utf8"); |
This file contains 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
<?php | |
// MySQLへ接続及びデータベースの選択 | |
$link = mysqli_connect("localhost", "testuser", "testuser", "uriage"); | |
if(mysqli_connect_errno() > 0){ | |
die("接続失敗" . mysqli_connect_error()); | |
} | |
// 文字化け防止 | |
mysqli_set_charset($link, "utf8"); |
This file contains 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
<?php | |
// MySQLへ接続 | |
$link = mysqli_connect("localhost", "testuser", "testuser"); | |
if(mysqli_connect_errno() > 0){ | |
die("接続失敗" . mysqli_connect_error()); | |
} | |
// データベースの選択 | |
$db = mysqli_select_db($link, "uriage"); |
This file contains 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
<?php | |
// MySQLへ接続 | |
$link = mysql_connect("localhost", "testuser", "testuser"); | |
if (!$link) { | |
die("接続失敗" . mysql_error()); | |
} | |
// データベースの選択 | |
$db = mysql_select_db("uriage"); |
NewerOlder