通过php连接mysql出现问题
执行如下代码:
<?php
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
printf("Host information: %s\n", $mysqli->host_info);
/* close connection */
$mysqli->close();
?>
但是出现以下错误:
Fatal error: Class 'mysqli' not found in E:\web\PHPDocument1.php on line 2
执行以下代码:
<?php
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
/* check connection */
if (!$link) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
printf("Host information: %s\n", mysqli_get_host_info($link));
/* close connection */
mysqli_close($link);
?>
出现如下错误:
Fatal error: Call to undefined function mysqli_connect() in E:\web\PHPDocument1.php on line 2
我的mysql版本是5.0.20,我的php版本是5.1.1