I am trying to de-duplicate entries in one of my MySQL tables but I keep getting the same error.
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in C:\Inetpub\vhosts\myexamplewebsite.com\httpdocs\duplicate\index.php on line 25
What am I doing wrong please?
<?php
$dedupe=mysqli_connect("localhost","user","pass","database");
$result = mysqli_query($dedupe,"SELECT * FROM `videos` WHERE `dupe`=0 order by RAND() ");
while($row = mysqli_fetch_array($result))
{
$vod_index = $row['index'];
$vod_video_name = $row['video_name'];
$vod_vidstart = $row['vidstart'];
$vod_providerid = $row['providerid'];
$vod_dupe = $row['dupe'];
$result2 = mysqli_query($dedupe,"SELECT * FROM `videos` WHERE `index` != '$vod_index';
AND `dupe`='0'
AND `video_name` = '$vod_video_name'
AND `vidstart` = '$vod_vidstart'
AND `providerid` = '$vod_providerid'
AND `index` != '$vod_index'
");
while($row2 = mysqli_fetch_array($result2))
{
$vod_index2 = $row2['index'];
$vod_video_name2 = $row2['video_name'];
$vod_vidstart2 = $row2['vidstart'];
$vod_providerid2 = $row2['providerid'];
$vod_dupe2 = $row2['dupe'];
mysqli_query($dedupe,"UPDATE `videos` set `dupe`=1
WHERE `index`='$vod_index2' ");
{
echo("Error description: " . mysqli_error($recordcon));
}
mysqli_query($dedupe,"INSERT INTO deduped (index,videos_index)
VALUES ('NULL','$vod_index2')");
}
}
mysqli_close($dedupe);
?>
Please note: index
is the primary key for the table.
I would prefer to fix this method than start another if possible as I wrote this as a simpler one for me to understand than examples I was finding that other people have written.
Any help is appreciated.