23

我有这个代码(我知道电子邮件已定义)

 <?php
$con=mysqli_connect($host,$user,$pass,$database);
 if (mysqli_connect_errno($con))
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT `note` FROM `glogin_users` WHERE email = '.$email.'");

while($row = mysqli_fetch_array($result))
echo $row
?>

在我的 MySQL 数据库中,我有以下设置(表名是 glogin_users) id email note

我尝试从数据库中提取注释文本,然后对其进行回显,但它似乎没有回显任何内容。

4

3 回答 3

39

您现在正在做的是添加.字符串而不是连接。它应该是,

$result = mysqli_query($con,"SELECT `note` FROM `glogin_users` WHERE email = '".$email."'");

或者干脆

$result = mysqli_query($con,"SELECT `note` FROM `glogin_users` WHERE email = '$email'");
于 2013-03-29T12:52:14.740 回答
4
$result = mysqli_query($con,"SELECT `note` FROM `glogin_users` WHERE email = '".$email."'");
while($row = mysqli_fetch_array($result))
echo $row['note'];
于 2013-03-29T13:40:56.177 回答
3

你必须这样做才能回应它:

echo $row['note'];

(数据以数组形式出现)

于 2013-03-29T12:55:06.517 回答