[PHP]MySQL連接方法

<?php
//php顯示編碼
header("Content-Type:text/html; charset=utf-8");

//連接資料庫
$con = mysql_connect("localhost", "philip", "philip01");
mysql_query("set names utf8");

//連接狀態結果
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

$db_selected = mysql_select_db("teaching_english", $con);

if (!$db_selected)
  {
  die ("Can\'t use test_db : " . mysql_error());
  }
?>

留言

這個網誌中的熱門文章

[Arduino]電子秤平 重量感測條+HX711AD模組

cpe練習筆記 UVa401 Palindromes

cpe練習筆記 UVa10019 Funny Encryption Method