gpt4 book ai didi

php - 简单的 SQL 查询从表中选择,其中 email = email

转载 作者:行者123 更新时间:2023-11-29 07:18:43 25 4
gpt4 key购买 nike

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

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

我正在运行 SQL 查询来从表成员中进行选择,其中电子邮件 = $email 且密码 =$pass。

然后我运行 mysqli_query 来查看是否存在一行,但没有得到任何结果。当然,回显会回显信息匹配的 ID。

//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 注入(inject)......您正在查询数据,但未获取结果。

添加获取命令:

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

关于php - 简单的 SQL 查询从表中选择,其中 email = email,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36893238/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com