Wordpress simple_html_dom.php admin page












0















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!










share|improve this question




















  • 1





    A good start would be to enable error reporting with error_reporting(E_ALL); and ini_set('display_errors', 1); Start from there.. I suspect that some includes are missing and you have to use the global $db object to access the db in WP.

    – Eriks Klotins
    Nov 27 '18 at 23:39













  • Thank you, Eriks! Looks like I've made a mistake by getting the error messages out, because earlier they weren't working. Now it doesn't look like if find find() in the file_get_html. Updatd main post. Thx!

    – Kristian
    Nov 28 '18 at 9:50


















0















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!










share|improve this question




















  • 1





    A good start would be to enable error reporting with error_reporting(E_ALL); and ini_set('display_errors', 1); Start from there.. I suspect that some includes are missing and you have to use the global $db object to access the db in WP.

    – Eriks Klotins
    Nov 27 '18 at 23:39













  • Thank you, Eriks! Looks like I've made a mistake by getting the error messages out, because earlier they weren't working. Now it doesn't look like if find find() in the file_get_html. Updatd main post. Thx!

    – Kristian
    Nov 28 '18 at 9:50
















0












0








0








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!










share|improve this question
















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!







php wordpress simple-html-dom






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 28 '18 at 9:52







Kristian

















asked Nov 27 '18 at 23:12









KristianKristian

205




205








  • 1





    A good start would be to enable error reporting with error_reporting(E_ALL); and ini_set('display_errors', 1); Start from there.. I suspect that some includes are missing and you have to use the global $db object to access the db in WP.

    – Eriks Klotins
    Nov 27 '18 at 23:39













  • Thank you, Eriks! Looks like I've made a mistake by getting the error messages out, because earlier they weren't working. Now it doesn't look like if find find() in the file_get_html. Updatd main post. Thx!

    – Kristian
    Nov 28 '18 at 9:50
















  • 1





    A good start would be to enable error reporting with error_reporting(E_ALL); and ini_set('display_errors', 1); Start from there.. I suspect that some includes are missing and you have to use the global $db object to access the db in WP.

    – Eriks Klotins
    Nov 27 '18 at 23:39













  • Thank you, Eriks! Looks like I've made a mistake by getting the error messages out, because earlier they weren't working. Now it doesn't look like if find find() in the file_get_html. Updatd main post. Thx!

    – Kristian
    Nov 28 '18 at 9:50










1




1





A good start would be to enable error reporting with error_reporting(E_ALL); and ini_set('display_errors', 1); Start from there.. I suspect that some includes are missing and you have to use the global $db object to access the db in WP.

– Eriks Klotins
Nov 27 '18 at 23:39







A good start would be to enable error reporting with error_reporting(E_ALL); and ini_set('display_errors', 1); Start from there.. I suspect that some includes are missing and you have to use the global $db object to access the db in WP.

– Eriks Klotins
Nov 27 '18 at 23:39















Thank you, Eriks! Looks like I've made a mistake by getting the error messages out, because earlier they weren't working. Now it doesn't look like if find find() in the file_get_html. Updatd main post. Thx!

– Kristian
Nov 28 '18 at 9:50







Thank you, Eriks! Looks like I've made a mistake by getting the error messages out, because earlier they weren't working. Now it doesn't look like if find find() in the file_get_html. Updatd main post. Thx!

– Kristian
Nov 28 '18 at 9:50














2 Answers
2






active

oldest

votes


















0














Moving my earlier comment and some more hints here.



A good start would be to enable error reporting with



error_reporting(E_ALL);
ini_set('display_errors', 1);


Start from there.. I suspect that some includes are missing and you have to use the global $db object to access the DB in WP.



Looking at your errors - apparently, $html variable is boolean and not a htmlDOM object. According to this, file_get_html() returns false, if fetched content is empty or exceeds MAX_FILE_SIZE.



Check if the URL you are retrieving really exists, you have rights to access it, and MAX_FILE_SIZE is set correctly






share|improve this answer































    0














    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! :)







    share|improve this answer























      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53509662%2fwordpress-simple-html-dom-php-admin-page%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      Moving my earlier comment and some more hints here.



      A good start would be to enable error reporting with



      error_reporting(E_ALL);
      ini_set('display_errors', 1);


      Start from there.. I suspect that some includes are missing and you have to use the global $db object to access the DB in WP.



      Looking at your errors - apparently, $html variable is boolean and not a htmlDOM object. According to this, file_get_html() returns false, if fetched content is empty or exceeds MAX_FILE_SIZE.



      Check if the URL you are retrieving really exists, you have rights to access it, and MAX_FILE_SIZE is set correctly






      share|improve this answer




























        0














        Moving my earlier comment and some more hints here.



        A good start would be to enable error reporting with



        error_reporting(E_ALL);
        ini_set('display_errors', 1);


        Start from there.. I suspect that some includes are missing and you have to use the global $db object to access the DB in WP.



        Looking at your errors - apparently, $html variable is boolean and not a htmlDOM object. According to this, file_get_html() returns false, if fetched content is empty or exceeds MAX_FILE_SIZE.



        Check if the URL you are retrieving really exists, you have rights to access it, and MAX_FILE_SIZE is set correctly






        share|improve this answer


























          0












          0








          0







          Moving my earlier comment and some more hints here.



          A good start would be to enable error reporting with



          error_reporting(E_ALL);
          ini_set('display_errors', 1);


          Start from there.. I suspect that some includes are missing and you have to use the global $db object to access the DB in WP.



          Looking at your errors - apparently, $html variable is boolean and not a htmlDOM object. According to this, file_get_html() returns false, if fetched content is empty or exceeds MAX_FILE_SIZE.



          Check if the URL you are retrieving really exists, you have rights to access it, and MAX_FILE_SIZE is set correctly






          share|improve this answer













          Moving my earlier comment and some more hints here.



          A good start would be to enable error reporting with



          error_reporting(E_ALL);
          ini_set('display_errors', 1);


          Start from there.. I suspect that some includes are missing and you have to use the global $db object to access the DB in WP.



          Looking at your errors - apparently, $html variable is boolean and not a htmlDOM object. According to this, file_get_html() returns false, if fetched content is empty or exceeds MAX_FILE_SIZE.



          Check if the URL you are retrieving really exists, you have rights to access it, and MAX_FILE_SIZE is set correctly







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 28 '18 at 10:25









          Eriks KlotinsEriks Klotins

          1,3831518




          1,3831518

























              0














              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! :)







              share|improve this answer




























                0














                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! :)







                share|improve this answer


























                  0












                  0








                  0







                  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! :)







                  share|improve this answer













                  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! :)








                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 28 '18 at 11:57









                  KristianKristian

                  205




                  205






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53509662%2fwordpress-simple-html-dom-php-admin-page%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Contact image not getting when fetch all contact list from iPhone by CNContact

                      count number of partitions of a set with n elements into k subsets

                      A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks