PHP MySQLI调用未定义的方法mysqli_stmt :: bind_params()

时间:2015-01-14 13:41:32

标签: php mysqli

我的一位朋友目前还没有大量帮助这个脚本我目前正在更新我的旧脚本但是它会出现以下错误消息;

  

致命错误:调用未定义的方法mysqli_stmt :: bind_params()

    $stmt = $db->prepare( $sql ); 
    if (!$stmt) 
    { 
        die("Failed to prepare statement: " . $sql); 
    } 

    // here I only get the title, website, and summary from the <form> 
    // that posted to this page: 
    $title = $_POST["news_title"]; 
    $img  = $_POST["news_imgPath"]; 
    $desc  = $_POST["news_content"];
    $more  = $_POST["news_websitePath"];

    $stmt->bind_params("ssss", $title, $img, $desc, $more ); 

    if ( ! $stmt->execute() ) 
    { 
        die("Execution of bound statement failed: " . $stmt->error); 
    } 

    echo "Inserted {$stmt->affected_rows} correctly.<hr/>"; 

    $db->close();

2 个答案:

答案 0 :(得分:4)

  

致命错误:调用未定义的方法mysqli_stmt :: bind_params()

bind_param ,而不是bind_params()

                         ^

答案 1 :(得分:3)

你拼错了bind_param

$stmt->bind_param("ssss", $title, $img, $desc, $more );