使用PHP更新查询不起作用 [英] Update query is not working using php

查看:90
本文介绍了使用PHP更新查询不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将id no传递给Url并从GET函数获取id,但由于MD5而传递给URL的id no却不接受更新查询.我尝试了$id=md5($_GET['user']);,但仍然遇到问题.我的user_id为1,它将转换为md5编号并传递给update函数以更新表.您能帮我吗?

I am passing id no to Url and get the id from GET function but id no which I passed to URL that not accepting the update query because of MD5. I tried $id=md5($_GET['user']); but still getting issue. My user_id is 1 and that is converting into the md5 number and passing to update function to update the table. Would you help me in this?

$User_id1=1;
$user_id=md5($User_id1);

http://www.domaine.com/process.php?user=$user_id

if(isset($_GET['user']))
{
$id=$_GET['user'];
$sql="UPDATE request SET email_verification=1 WHERE Id='$id'";
$result = $conn->query($sql);
if ($result=== TRUE) {
    header('Location: index.php');
} else {
    echo "Error updating record: " . $conn->error;
}
}

推荐答案

我不认为您的md5-ied user_id传递到更新查询中,因为如果条件内部没有md5()函数正在执行任务,并且您还必须确保值如何存储在数据库内部,是md5-eded user_id还是普通的user_id?如果是md5 user_id,请尝试这样,

I don't think your md5-ied user_id is passing into update query because inside top if condition there is no md5() function which is doing the task and you must also sure that how is value stored inside the database, is it md5-ied user_id or normal user_id ? if for md5 user_id try it like this,

if(isset($_GET['user'])){
    $id = $_GET['user'];
    $id = md5($id);
    $sql = "UPDATE request SET email_verification=1 WHERE Id='$id'";
    $result = $conn->query($sql);
    if ($result === TRUE) {
        header('Location: index.php');
    }
    else {
        echo "Error updating record: " . $conn->error;
    }
}

这篇关于使用PHP更新查询不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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