doueta6642 2018-11-27 23:12 采纳率: 0%
浏览 41
已采纳

Wordpress simple_html_dom.php管理页面

I've made as script using file_get_html. I'm now transfering it to a Wordpress site, and it doesn't seem to work.

Just trying to use it in a admin plugin.

Snippet below:

require('includes/simple_html_dom.php');
if (isset($_POST['submit_updateColors'])) {
        $qGetBrands = $mysqli->query("SELECT ... ");
        while ($rowBrands = $qGetBrands->fetch_assoc()) {

            $brandId = $rowBrands['cl_brand_Id'];
            $url =  "https://www.url.com". $rowBrands['cl_brand_url'];
            $html = file_get_html($url);
            $html->find('div[class=col-md-1p5]');

            foreach($html->find('div[class=col-md-1p5]') as $brandColors) {
                foreach ($brandColors->find('h3') as $brandColor) {
                    $p_brandColor = $brandColor->innertext;
                }

                foreach ($brandColors->find('img') as $ColorImg) {
                    $p_ColorImg = $ColorImg->src;
                }                   
                    echo $p_brandColor ." <br />";
                    echo $imgName['basename'] ." <br /> <br />";
            }
        }
    }

After while have started: echo "I'm here!!!" Results: "I'm here!!!"

After first foreach: echo "I'm here!!!" Results: Nothing

After $html = file_get_html($url);: echo "Result: ".$html; Results: Nothing, not even showing "Result"

Error messages:

Fatal error: Uncaught Error: Call to a member function find() on boolean in /home/xxx/public_html/wp-content/plugins/Farbkarte/index.php:67 Stack trace: #0 /home/xxx/public_html/wp-includes/class-wp-hook.php(286): main_init('') #1 /home/xxx/public_html/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters('', Array) #2 /home/xxx/public_html/wp-includes/plugin.php(453): WP_Hook->do_action(Array) #3 /home/xxx/public_html/wp-admin/admin.php(224): do_action('toplevel_page_f...') #4 {main} thrown in /home/xxx/public_html/wp-content/plugins/Farbkarte/index.php on line 67

I have no idea how to proceed, and would love to get some help! Outside wordpress, it works perfectly.

I hope I havent removed too much informaton.

Thanks in advance!

  • 写回答

2条回答 默认 最新

  • doupeng6890 2018-11-28 11:57
    关注

    I was able to solve this by looking at file_get_contents(): stream does not support seeking / When was PHP behavior about this changed?

    On line 75 of simple_html_dom.php:

    $contents = file_get_contents($url, $use_include_path, $context, $offset); I removed the reference to $offset:

    $contents = file_get_contents($url, $use_include_path, $context); No my page works fine. Not taking liability for anything else it breaks! :)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题