gpt4 book ai didi

PHP 回显 MySQL SELECT 的结果

转载 作者:行者123 更新时间:2023-11-29 08:13:21 24 4
gpt4 key购买 nike

我有这个 PHP(测试):

<?php
if (isset($_POST['submit'])) {

$link = mysqli_connect("localhost","php","","A");

$query = "SELECT passport FROM users WHERE mail = '$_POST[mail]';";

$result = $link->query($query);

}
?>

使用相同的 $query 进行手动选择显示:

mysql> SELECT passport FROM users WHERE mail = 'WhoMe@domain.com';
+----------------------+
| passport |
+----------------------+
| 8KQSWCZPJAUV1M9D4TFG |
+----------------------+
1 row in set (0.00 sec)

我试图在 PHP 中回显 $result ,它应该显示 8KQSWCZPJAUV1M9D4TFG 但它是空的。我在这里做错了什么?

更新:

<?php
if (isset($_POST['submit'])) {

$link = mysqli_connect("localhost","php","","A");

$query = "SELECT passport FROM users WHERE mail = '$_POST[mail]';";

$result = mysqli_query($query);

$row = mysqli_fetch_assoc($result);

echo $row["passport"];

}
?>

这仍然是空的。

最佳答案

尝试一下:

$result = mysqli_query($query);
$row = mysqli_fetch_assoc($result);

关于PHP 回显 MySQL SELECT 的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21110730/

24 4 0