MYSQLI prepared statement bind_param types does not work

后端 未结 2 549
余生分开走
余生分开走 2021-01-26 00:45

I have been using prepared insert statements for some years and assumed it was binding parameters properly or would give an error but it seems not as the following php binds and

2条回答
  •  我在风中等你
    2021-01-26 00:59

    I'm not an expert for sure, but at first look. You have:

    $id1 = 'aaaaaaa';
    $id2= 'aaaaaaa';
    $result = $stmt->bind_param('ii', $id1, $id2);
    

    Thing is your 'ii' parameter says that you will be binding integers! And in fact your $id1 and $id2 are strings. For strings you should go with:

    $result = $stmt->bind_param('ss', $id1, $id2);
    

提交回复
热议问题