代码已成功连接到数据库但是当我尝试从数据库中检索数据时,它无法正常工作。
<?php
$link = mysqli_connect("server name","username","password");
if (mysqli_connect_error()) {
die ("There was an error connecting to the database");
}
$query = "SELECT * FROM users";
if ($result = mysqli_query($link, $query)) {
$row = mysqli_fetch_array($result);
echo "Your email is ".$row[1]." and your password is ".$row[2];
} else {
echo mysqli_error($link);
}
?>
答案 0 :(得分:2)
你没有指定搜索哪个数据库,在mysqli上你应该再添加一个参数
$link = mysqli_connect("server name","username","password", "database");