mysql_connect有效,mysqli没有

时间:2013-05-01 17:25:51

标签: php mysql mysqli

像魅力一样:

mysql_connect('localhost') or die('Could not connect to MySQL database');
mysql_select_db('k') or die('Couldnt select MySQL database in connect.php');

这两个都因内部服务器错误(500)而失败

$mysqli = new mysql('localhost',null,null,'k');
$mysqli = new mysql('localhost','','','k');

2 个答案:

答案 0 :(得分:2)

您错过了i

中的mysqli
$mysqli = new mysql('localhost',null,null,'k');
$mysqli = new mysql('localhost','','','k');

应该是

$mysqli = new mysqli('localhost',null,null,'k');
$mysqli = new mysqli('localhost','','','k');

答案 1 :(得分:0)

它应该是new mysqli(..而不是new mysql(..

$mysqli = new mysqli('localhost',null,null,'k');
$mysqli = new mysqli('localhost','','','k');

查看constructor

的手册