<?php
// Create connection
$con=mysql_connect('localhost','root','');//mysqli_connect(host,username,password,dbname);
mysql_select_db('stat');
// Check connection
if (mysqli_connect_errno($con))
echo "Failed to connect to MySQL: " . mysqli_connect_error();
else
echo "yes\n";
$sql = "INSERT INTO stat VALUES (NULL, \'2012-09-02\', \'1000\')";
$result2 = mysql_query($sql) or die(mysql_error());
mysql_close($con);
?>
选择了 DB,但 msql.error() 返回“未选择数据库”!为什么?