Note that there are some explanatory texts on larger screens.

plurals
  1. POMysqli Prepared Statement problem
    primarykey
    data
    text
    <p>i use MYSQLI Extension with prepared statements, what im doing is video encoding, the encoding works, but i have trouble with MYSQL</p> <p>When the code reaches i get 2 errors ONE is</p> <pre><code>PHP Fatal error: Call to a member function bind_param() on a non-object in /site.com/processor.php on line 108 </code></pre> <p>HERE the SQL</p> <pre><code> $sql = "UPDATE videos_to_edit SET status = 'finished' WHERE post_id = ?"; $stmt = $mysqli-&gt;prepare($sql); $stmt-&gt;bind_param('i', $id); $stmt-&gt;execute(); $stmt-&gt;close(); </code></pre> <p>and when I <code>var_dump($stmt)</code> it shows bool false. I noticed also, when i encode a other video it works but sometimes it dont works. (always the mysql error) When I comment out this line</p> <pre><code> exec("$mencoder $temp_upload_dir$post_filename -o $temp_upload_dir$r_post_id.mp4 2&gt;&amp;1", $output); </code></pre> <p>than MYSQLI works, but i need this line to encode my video. Any Ideas what i doing wrong?</p> <pre><code>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-&gt;prepare($sql); $stmt-&gt;execute(); $stmt-&gt;bind_result($r_post_id, $post_filename, $status); $stmt-&gt;store_result(); $checker = $stmt-&gt;num_rows; $stmt-&gt;fetch(); $stmt-&gt;close(); $id = $r_post_id; //$video = null; if($checker &gt;= 1 &amp;&amp; $status != "encoding" &amp;&amp; $status != "finished" &amp;&amp; $status != "removed" ) { $sql = "UPDATE videos_to_edit SET status = 'encoding' WHERE post_id = ?"; $stmt = $mysqli-&gt;prepare($sql); $stmt-&gt;bind_param('i', $r_post_id); $stmt-&gt;execute(); $stmt-&gt;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&gt;&amp;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&gt;&amp;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 &lt;= 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&gt;&amp;1", $mplayer); } $sql = "UPDATE videos_to_edit SET status = 'finished' WHERE post_id = ?"; $stmt = $mysqli-&gt;prepare($sql); $stmt-&gt;bind_param('i', $id); $stmt-&gt;execute(); $stmt-&gt;close(); $sql = "INSERT INTO post_lenght (post_id, post_length, seconds) VALUES (?, ?, ?)"; $stmt = $mysqli-&gt;prepare($sql); $stmt-&gt;bind_param('iss', $r_post_id, $hms, $duration); $stmt-&gt;execute(); $stmt-&gt;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-&gt;prepare($sql); $stmt-&gt;bind_param('i', $r_post_id); $stmt-&gt;execute(); $stmt-&gt;close(); unlink($pcp ."processor1"); } } exit; } </code></pre> <p>Solution: i had this variables in <code>my.cnf</code> set on</p> <pre><code>wait_timeout = 30 interactive_timeout = 60 </code></pre> <p>i changed them into </p> <pre><code>wait_timeout = 3600 interactive_timeout = 3600 </code></pre> <p>and it works, i will google some if i can change these variables in the script, if yes i will do it so, cause i remember the high numbers caused by me RAM problems.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload