dongtang8678 2010-11-13 04:42
浏览 66
已采纳

我可以在更新中使用mysql的md5函数吗?

I don't know how to ask this so I'll start with what I have already:

mysql_query("UPDATE `questions` SET `votes` = `votes` + 1 
WHERE `questionID`='".md5($_GET['q'])."'");

What I want to do is update the row where the md5 hashed version of questionID = some string. Can I do this using MySQL's md5 function?

Edit:

Would it be something like this then:

"WHERE MD5(`questionID`)='".md5($_GET['q'])."'"
  • 写回答

3条回答 默认 最新

  • dongshao1156 2010-11-13 04:45
    关注

    You could, but in that code you're using PHP's md5.

    EDIT: If you want to search for a row where the hash of the questionID column equals the hash of $_GET['q'], the second looks right. It's not clear what you're using MD5 for, though. Maybe you should give some background.

    EDIT 2: Since q is already hashed, it should be (with escaping):

    "WHERE MD5(`questionID`)='" . mysql_real_escape_string($_GET['q']) . "'"
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥30 Unity接入微信SDK 无法开启摄像头
  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源