Created
August 31, 2014 08:10
-
-
Save QETHAN/c7ac5db00889dca7bb45 to your computer and use it in GitHub Desktop.
php MySQL连接
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
<?php | |
$link = mysql_connect('127.0.0.1', 'code1', '') or die('数据库连接失败'); | |
mysql_select_db('code1'); | |
mysql_query("set names 'utf8'"); | |
$result = mysql_query('select * from user limit 1'); | |
$row = mysql_fetch_array($result); | |
print_r($row); | |
PDO扩展 | |
$dsn = 'mysql:dbname=testdb;host=127.0.0.1'; | |
$user = 'dbuser'; | |
$password = 'dbpass'; | |
$dbh = new PDO($dsn, $user, $password); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment