I use OctoberCMS and have this code in a backend of a page which gets all links from specific page
$html = file_get_contents("http://somepage.com/");
$doc = new DOMDocument();
libxml_use_internal_errors(true);
$doc->loadHTML($html);
libxml_clear_errors();
$xpath = new DOMXPath($doc);
foreach ($doc->getElementsByTagName('a') as $link){
if (parse_url($link->getAttribute('href'), PHP_URL_SCHEME) === 'https') {
$links[] = array('url' => $link->getAttribute('href'));
}
$haystack = $link->getAttribute('href');
$needle = "ht";
if( strpos( $haystack, $needle ) !== false ) {
echo $haystack."<br>";
}
else
{
continue;
}
}
But whenever I try to load the page itself,which has only 2 links, I get constant loops and page won't load at all, resulting server to return an SQLSTATE[HY000] [1203] User ahmcho_ahmad already has more than 'max_user_connections' active connections
error to me. I do not understand why I get this error?