当我运行代码时,它只显示声明失败的回声,我认为没有丢失的括号或引号
<?php
$link = mysqli_connect("localhost", "id1242269_sql", "pass", "id1242269_sql");
if (mysqli_connect_error()) {
die("Could not connect to database");
}
$query = "SELECT * FROM users";
if ($result=mysqli_query($link, $query)) {
while ($row = mysqli_fetch_array($result)) {
print_r($row);
}
} else {
echo "it failed";
}
?>
答案 0 :(得分:0)
这是mysqli_error()派上用场的地方。
if ($result=mysqli_query($link, $query)) {
while ($row = mysqli_fetch_array($result)) {
print_r($row);
}
} else {
printf("Errormessage: %s\n", mysqli_error($link)); // Print error message
}
答案 1 :(得分:0)
$link = mysqli_connect("localhost", "id1242269_sql", "pass", "id1242269_sql");
我是新手,但在我的作业中我们使用了&#34; new&#34;在那里:
$link = new mysqli_connect("localhost", "id1242269_sql", "pass", "id1242269_sql");
答案 2 :(得分:0)