最佳答案
我已经搜索了网络,到目前为止,我看到的是,你可以使用 mysql_
和 mysqli_
一起意味着:
<?php
$con=mysqli_connect("localhost", "root" ,"" ,"mysql");
if( mysqli_connect_errno( $con ) ) {
echo "failed to connect";
}else{
echo "connected";
}
mysql_close($con);
echo "Done";
?>
或者
<?php
$con=mysql_connect("localhost", "root" ,"" ,"mysql");
if( mysqli_connect_errno( $con ) ) {
echo "failed to connect";
}else{
echo "connected";
}
mysqli_close($con);
echo "Done";
?>
是有效的,但是当我使用这个代码时,我得到的是:
Connected
Warning: mysql_close() expects parameter 1 to be resource, object given in D:\************.php on line 9
Done
对于第一个和相同的除了与 mysqli_close()
。对于第二个。
What is the problem? Can't I use mysql_
and mysqli
together? Or is it normal? Is the way I can check if the connections are valid at all? (the if(mysq...)
)