从表中选择简单的SQL查询,其中email = email [英] Simple SQL query selecting from table where email = email

查看:74
本文介绍了从表中选择简单的SQL查询,其中email = email的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个名为$ email和$ pass的php值.

I've got two php values called $email and $pass.

email-MySQL数据库中的行名 密码-MYSQL数据库中的行名

email - Name of row in MySQL database password - Name of row in MYSQL database

我正在运行一个SQL查询,以从表成员中进行选择,其中email = $ email和password = $ pass.

I'm running a sql query to select from table member where email = $email and password =$pass.

然后我正在运行mysqli_query来查看是否存在行,但没有得到任何结果.回声肯定会回显出信息匹配的ID.

I'm then running mysqli_query to see if a row exists, I'm not getting any results. Surely the echo would echo out the ID of where the info matches.

//Get the connection info. 
global $connect;

$sql = "SELECT FROM members WHERE email='$email' AND password='pass'";

//Fetch the row and store the ID of this row.
$row = mysqli_query($connect, $sql);
$id = $row['userID'];

echo $id;

推荐答案

除了该代码已大量暴露于SQL注入这一事实之外,您还在查询数据但未获取结果.

Besides the fact that this code is massively exposed to SQL injection.. you are querying the data but not fetching the results.

添加提取命令:

$data = mysqli_query($connect, $sql);
$row = mysqli_fetch_assoc($data);
$id = $row['userID'];

这篇关于从表中选择简单的SQL查询,其中email = email的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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