dqitk20644 2014-11-21 03:16
浏览 11

我的PHP PHP重复数据删除器出了什么问题?

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.

  • 写回答

1条回答 默认 最新

  • douye2036 2014-11-21 03:44
    关注

    You have an unexpected semicolon in your query, try it like this:

    $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'
         ");
    
    评论

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么