加入收藏 | 设为首页 | 会员中心 | 我要投稿 云计算网_宿迁站长网 (https://www.0527zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MySql教程 > 正文

mysql where子句bug?

发布时间:2022-11-25 21:31:41 所属栏目:MySql教程 来源:未知
导读: I programmed the following in php and mysql:
$id = $_GET['id'];
if ($stmt = $db->prepare("SELECT disco, fecha, amazon from discos where id=? LIMIT 1")) {
$stmt->bind_par

I programmed the following in php and mysql:

$id = $_GET['id'];  
if ($stmt = $db->prepare("SELECT disco, fecha, amazon from discos where id=? LIMIT 1")) {
    $stmt->bind_param("i", $id);    /* NOTE: "s" doesn't work */

    $stmt->execute();
    $stmt->bind_result($disco, $fecha, $amazon);        
    if($stmt->fetch()){
        /* Do some stuff */

    }
}

The thing is, when the value of $id is,for example: 100abcdMySQL where 子句, the query still fetches, whereas it shouldn't, as there is no id called like that, BUT it fetches the id 100.

Why is this happening? Thanks.

(编辑:云计算网_宿迁站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!