Php Mysqli准备语句问题

Php Mysqli准备语句问题,php,mysql,mysqli,prepared-statement,Php,Mysql,Mysqli,Prepared Statement,我使用MYSQLI扩展来准备语句,我做的是视频编码,编码是有效的,但是我在使用MYSQL时遇到了问题 当代码到达时,我得到两个错误,一个是 PHP Fatal error: Call to a member function bind_param() on a non-object in /site.com/processor.php on line 108 这里是SQL $sql = "UPDATE videos_to_edit SET status = 'finished' WH

我使用MYSQLI扩展来准备语句,我做的是视频编码,编码是有效的,但是我在使用MYSQL时遇到了问题

当代码到达时,我得到两个错误,一个是

PHP Fatal error:  Call to a member function bind_param() on a non-object in /site.com/processor.php on line 108
这里是SQL

    $sql = "UPDATE videos_to_edit SET status = 'finished' WHERE post_id = ?";
    $stmt = $mysqli->prepare($sql);
    $stmt->bind_param('i', $id);
    $stmt->execute();
    $stmt->close();
当我var_dump$stmt时,它显示bool false。我还注意到,当我对其他视频进行编码时,它可以工作,但有时不工作。当我注释掉这一行时,总是出现mysql错误

 exec("$mencoder $temp_upload_dir$post_filename -o $temp_upload_dir$r_post_id.mp4 2>&1", $output);
比MYSQLI工作,但我需要这一行编码我的视频。知道我做错了什么吗

set_time_limit(0);


if(!file_exists($pcp ."processor1")) {

    $sql = "SELECT post_id, filename, status FROM videos_to_edit WHERE status = 'pending' ORDER BY post_id ASC LIMIT 1";
    $stmt = $mysqli->prepare($sql);
    $stmt->execute();
    $stmt->bind_result($r_post_id, $post_filename, $status); 
    $stmt->store_result();
    $checker = $stmt->num_rows;
    $stmt->fetch();
    $stmt->close();
    $id = $r_post_id;
    //$video = null;

    if($checker >= 1 && $status != "encoding" && $status != "finished" && $status != "removed" ) {


        $sql = "UPDATE videos_to_edit SET status = 'encoding' WHERE post_id = ?";
        $stmt = $mysqli->prepare($sql);
        $stmt->bind_param('i', $r_post_id);
        $stmt->execute();
        $stmt->close();

        $ourFileName = $pcp ."processor1";
        $ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
        fclose($ourFileHandle);


        exec("$mencoder $temp_upload_dir$post_filename -o $temp_upload_dir$r_post_id.mp4 2>&1", $output);


        foreach($output as $error) {
            if(preg_match('/============ Sorry, this file format is not recognized\/supported =============/', $error)) {
                $error1 = "error";
                break;
            }
        }


        if(!isset($error1)) {

            exec("$mp4box $temp_upload_dir$r_post_id.mp4");

            exec("$mplayer $temp_upload_dir$r_post_id.mp4 2>&1", $video);

            foreach($video as $vidlenght) {
                if(preg_match('/ID_LENGTH=/', $vidlenght)) {
                    $duration = $vidlenght;
                    $duration = explode("=",$duration);
                    $duration = round($duration['1']);
                    break;
                }
            }

            $hms = sec2hms($duration);

            mkdir("$temp_upload_dir$r_post_id", 0700);

            $duration1 = round($duration / 15);

            for($b = 1; $b <= 15; $b++) {

            $time = $b * $duration1;

            exec("$ffmpeg -ss $time -i $temp_upload_dir$r_post_id.mp4 -r 1 -vframes 15 -y -s 190x143 -f image2 $temp_upload_dir/$r_post_id/$r_post_id-$b.jpg 2>&1", $mplayer);

            }

            $sql = "UPDATE videos_to_edit SET status = 'finished' WHERE post_id = ?";
            $stmt = $mysqli->prepare($sql);
            $stmt->bind_param('i', $id);
            $stmt->execute();
            $stmt->close();

            $sql = "INSERT INTO post_lenght (post_id, post_length, seconds) VALUES (?, ?, ?)";
            $stmt = $mysqli->prepare($sql);
            $stmt->bind_param('iss', $r_post_id, $hms, $duration);
            $stmt->execute();
            $stmt->close();

            $thumbdir1 = $temp_upload_dir . $r_post_id; 
            $thumbdest = $thumbdir.$r_post_id;

            $videotempdir = $temp_upload_dir . $r_post_id . ".mp4";
            $videodes = $videodir . $r_post_id . ".mp4";

            $videotempdirsrc = $temp_upload_dir . $post_filename;
            $videodessrc = $temp_upload_dir . "src/"    . $post_filename;

            full_copy($thumbdir1, $thumbdest);
            rename($videotempdir, $videodes );
            rename($videotempdirsrc, $videodessrc);

            recursiveDelete($thumbdir1);



            unlink($pcp ."processor1");

            unset($video);
            unset($hms);
            unset($vidlenght);
            unset($duration);

        } else {

            $sql = "UPDATE videos_to_edit SET status = 'error' WHERE post_id = ?";
            $stmt = $mysqli->prepare($sql);
            $stmt->bind_param('i', $r_post_id);
            $stmt->execute();
            $stmt->close();

            unlink($pcp ."processor1");
        }
    }
    exit;
}
我把它们换成了

wait_timeout = 3600
interactive_timeout = 3600

如果可以在脚本中更改这些变量,我会搜索一些,如果可以,我会这样做,因为我记得内存问题导致的高数字。

您可以使用可读性而不是打开和关闭检查prepare调用的返回值以查看是否成功。看看这对我的问题有什么帮助?抱歉,我不明白,因为您的准备呼叫不起作用,并且您尝试使用stmt,所以出现了错误。请将您的解决方案作为答案发布。问题不是这样。您可以使用is_readable而不是open和closing检查prepare调用的返回值以查看它是否成功。看看这对我的问题有什么帮助?抱歉,我不明白,因为您的准备呼叫不起作用,并且您尝试使用stmt,所以出现了错误。请将您的解决方案作为答案发布。问题不是这样。
wait_timeout = 3600
interactive_timeout = 3600