//生成一个连接
$db_connect=mysql_connect($dbhost,$username,$userpass) or die("Unable to connect to the
MySQL!");
//选择一个需要操作的数据库
mysql_select_db($dbdatabase,$db_connect);
//执行 MySQL 语句
$result=mysql_query("SELECT id,name FROM user");
//提取数据
$row=mysql_fetch_row($result);
$username=your_name;
$userpass=your_pass;
$dbhost=localhost;
$dbdatabase=your_database;
$db=new mysqli($dbhost,$username,$userpass,$dbdatabase);
if(mysqli_connect_error()){
echo 'Could not connect to database.';
exit;
}
$result=$db->query("SELECT id,name FROM user");
$row=$result->fetch_row();