php - Catchable fatal error Object of class DOMDocument could not be converted to string -
i lost error:
catchable fatal error object of class domdocument not converted string
this php code:
<?php require_once('includes/mysqlconnect.php'); require_once('includes/utility.php'); //calling utility $utility = new utility(); //creating connection $connection= new mysql(); $connection->connect(); $getcontent= file_get_contents('http://www.example.com/'); //echo $getcontent; //create new domdocument object $doc= new domdocument(); //load html domdoc libxml_use_internal_errors(true); $doc->loadhtml($getcontent); $utility->removeelementsbytagname('script', $doc); $utility->removeelementsbytagname('style', $doc); $utility->removeelementsbytagname('link', $doc); echo $doc->savehtml(); //insert html db try { $result=$connection->db_query("call finalaggregator.insert_html('$doc')"); if ($result==0){ echo "<span style='color:red;'>error! data saving processes unsuccessful</span>"; } else { echo "<span style='color:green;'>data saved!</span>"; } } catch (exception $e){ echo "<span color='color:red;'>error in storing data! please check store procedure.</span>"; } ?>
but end showing
dom document not converted string on line 29
i want store the value of $doc database.
when trying to call stored procedure mysql:
call finalaggregator.insert_html("<p>testing123</p>");
it working fine.
please me. new php.
my stored procedure follow:
create definer=`root`@`localhost` procedure `insert_html`( in html longtext) begin insert finalaggregator.site_html (html) values(html); end
you cannot use instance of domdocument
string in query. have explicitly convert html string first:
$html = $doc->savehtml(); $result = $connection->db_query("call finalaggregator.insert_html('$html')");
Comments
Post a Comment