$query = "
         SELECT
             id,
             overskrift,
             tekst,
             detaljer,
             varenummer,
             lager,
             vegt,
             pris,
             billede,
             fallow_id
         FROM davidsen_vare
         WHERE
             overskrift LIKE ? OR varenummer  LIKE ?)
         LIMIT 30";

    $Statement = $this->mysqli->prepare($query);
    $Statement->bind_param("ss","%$sogning%","%$sogning%");   //error here
    $Statement->execute();
    $Statement->bind_result($id,$overskrift,$tekst,$detaljer,$varenummer,$lager,$vegt,$pris,$billede,$fallow_id);


有人可以帮忙吗

最佳答案

 $query = "
SELECT

    id,
    overskrift,
    tekst,
    detaljer,
    varenummer,
    lager,
    vegt,
    pris,
    billede,
    fallow_id
FROM davidsen_vare

WHERE
( overskrift LIKE %?%
   OR varenummer  LIKE %?%)
   LIMIT 30";

    $Statement = $this->mysqli->prepare($query);
   $Statement->bind_param("ss",$sogning,$sogning);


要么

 $query = "
SELECT

    id,
    overskrift,
    tekst,
    detaljer,
    varenummer,
    lager,
    vegt,
    pris,
    billede,
    fallow_id
FROM davidsen_vare

WHERE
( overskrift LIKE ?
   OR varenummer  LIKE ?)
   LIMIT 30";

    $Statement = $this->mysqli->prepare($query);
    $Statement->bind_param("ss",'%'.$sogning.'%','%'.$sogning.'%');

关于php - 致命错误:无法在%$ name%中通过引用传递参数2,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/17694553/

10-11 02:48