Note that there are some explanatory texts on larger screens.

plurals
  1. PORegex not returning any matches independent of expression used
    primarykey
    data
    text
    <p>Ok here is the issue, I have been trying to build cURL script to check for dead links in a database. The links all look something like this <code>http://www.ltblekinge.se/download/18.9c16a31109c04a3e880003750</code>. The issue that I have is that no mater what regex "pattern" I use the <code>$url_list</code> remains empty. Any help would be appreciated!</p> <p><strong>Problematic part of Code</strong></p> <pre><code>&lt;?php /*Config*/ /*** mysql hostname ***/ $hostname = 'localhost'; /*** mysql username ***/ $username = 'root'; /*** mysql password ***/ $password = 'root'; /*curl setup of varibles*/ $excluded_domains = array( 'localhost', 'rollnstroll.se'); $max_connections = 10; $url_list = array(); $working_urls = array(); $dead_urls = array(); $not_found_urls = array(); $active = null; try { $dbh = new PDO("mysql:host=$hostname;dbname=blankett", $username, $password); $dbh-&gt;exec('SET CHARACTER SET utf8'); $dbh-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); /*** fetch into an PDOStatement object ***/ $sql = "SELECT * FROM `forms2`"; $stmt = $dbh-&gt;prepare("SELECT * FROM forms2"); $stmt-&gt;execute(); while ($d = $stmt-&gt;fetchAll()) { if (preg_match_all('/((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&amp;=\+\$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&amp;=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&amp;;%@.\w_]*)#?(?:[.\!\/\\w]*))?)/', $d['link_forms'], $matches)) { /***error code***/ if (preg_last_error() == PREG_NO_ERROR) { print 'There is no error.'; } else if (preg_last_error() == PREG_INTERNAL_ERROR) { print 'There is an internal error!'; } else if (preg_last_error() == PREG_BACKTRACK_LIMIT_ERROR) { print 'Backtrack limit was exhausted!'; } else if (preg_last_error() == PREG_RECURSION_LIMIT_ERROR) { print 'Recursion limit was exhausted!'; } else if (preg_last_error() == PREG_BAD_UTF8_ERROR) { print 'Bad UTF8 error!'; } else if (preg_last_error() == PREG_BAD_UTF8_ERROR) { print 'Bad UTF8 offset error!'; } foreach ($matches[1] as $url) { // exclude some domains $tmp = parse_url($url); if (in_array($tmp['host'], $excluded_domains)) { continue; } // store the url $url_list []= $url; } } } // remove duplicates $url_list = array_values(array_unique($url_list)); if (!$url_list) { die('No URL to check'); } } catch(PDOException $e) { echo $e-&gt;getMessage(); } </code></pre> <p><strong>DB Structure</strong></p> <pre><code>1 id int(10) No None AUTO_INCREMENT 2 master_id int(10) No None 3 name_form varchar(500) latin1_swedish_ci No None 4 link_form varchar(500) latin1_swedish_ci No None 5 date_added timestamp No CURRENT_TIMESTAMP </code></pre> <p><strong>Question</strong> Why is <code>$url_list</code>emtpy?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload