PHP MySQL查询其中x = $ variable [英] PHP MySQL Query Where x = $variable

查看:63
本文介绍了PHP MySQL查询其中x = $ variable的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have this code (I know that the email is defined)

 <?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 电子邮件 注意

In my MySQL database I have the following setup (Table name is glogin_users) id email note

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

I've tried extracting the note text from the database and then echo'ing it but it doesn't seem to echo anything.

推荐答案

您现在正在做的是在字符串上添加.而不是串联.应该是

What you are doing right now is you are adding . on the string and not concatenating. It should be,

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

或者简单地

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

这篇关于PHP MySQL查询其中x = $ variable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆