0

this little script will not update the database after update from mysql to MySQLi.

include $dirlib . 'dbo.php';
if(!empty($_GET['list_vid'])) {
foreach ($_GET['list_vid'] as $position => $item) {
        $query  = mysqli_query($sql[] = "UPDATE $dbmov SET sort = '$position' WHERE id = $item");
        $result = mysqli_query($GLOBALS["___mysqli_ston"], $query);

err('sorting videos'));

1 Answers1

1

Run a prepared statement instead, that you can execute multiple times over. Its simpler, and safer.

Your current issue is that you were executing an array the first time around, and an object the second time around - doesn't quite work like that.

$query = "UPDATE $dbmov SET sort = ? WHERE id = ?";
$stmt = $GLOBALS["___mysqli_ston"]->prepare($query);
$stmt->bind_param("ss", $position, $item);
foreach ($_GET['list_vid'] as $position => $item) {
    $stmt->execute();
}  
$stmt->close();
Qirel
  • 25,449
  • 7
  • 45
  • 62