How to resolve 'cannot pass parameter by reference' error in PHP?

前端 未结 2 1381
醉梦人生
醉梦人生 2020-12-11 02:10

Here\'s my code:

$stmt = $conn->mysqli->prepare(\'INSERT INTO photos (CaseNo, ImageName, CaptureTime, UploadTime) VALUES (?,?,?,?)\');
$stmt->bind_p         


        
相关标签:
2条回答
  • 2020-12-11 02:39

    Change

    $stmt->bind_param('isss', $caseno, $index.'.'.$extension, $captureTime, $uploadTime);
    

    to

    $isss = 'isss';
    $indexExtention = $index.'.'.$extension
    $stmt->bind_param($isss, $caseno, $indexExtention , $captureTime, $uploadTime);
    

    I believe you have to pass variables rather than a string.

    Or you could use bindvalue() instead of bindparam() if you're using PDO.

    0 讨论(0)
  • 2020-12-11 02:49

    Maybe you need to cast it to string?

    ...$extension, (string) $captureTime, (string) $uploadTime);
    
    0 讨论(0)
提交回复
热议问题