Baclink Verifier

Can someone take a look at this script. Sometimes it work but most of the time it doesnt. I know the links are there but its echoing not found for some reason

[php]

<?php mysql_select_db($database_connection, $connection); $query_links = "SELECT * FROM links WHERE id = '$id'"; $links = mysql_query($query_links, $connection) or die(mysql_error()); $row_links = mysql_fetch_assoc($links); $totalRows_links = mysql_num_rows($links); $siteURL = $row_links['site_url'];; $recip_link = $row_links['recip_url']; function check_back_link($recip_link, $siteURL) { $match_pattern = preg_quote(rtrim($siteURL, "/"), "/"); $found = false; if ($handle = @fopen($recip_link, "r")) { while (!feof($handle)) { $part = fread($handle, 1024); if (preg_match("/(.*)/", $part)) { $found = true; break; } } fclose($handle); } return $found; } if (check_back_link($recip_link, $siteURL)) { echo "Link Found"; } else { echo "Link Not Found"; } ?>

[/php]

I was scouring through php.net to try and find the answer when i came across get_file_contents. so I had a play about with it and came up with this

[php]

<?php $partnersURL=$row_Recordset1['recip_url']; $htmlString=file_get_contents($partnersURL); if (ereg('"http://www.yourdomain.com" ', $htmlString)) { echo "'link found on $partnersURL
"; } else { echo "Link not found on $partnersURL
"; } ?>

[/php]

And it works perfectly

btw: thx for always posting the solutions u found on ur own.

I do that incase I do something wrong in the code so someone more experience can point out my mistakes.

Like in this code there is an error of sorts.

when used in a repeat

[php]

<?php do { ?> <?php echo $row_Recordset1['id']; ?> <?php echo $row_Recordset1['site']; ?> <?php $htmlString=file_get_contents($partnersURL); if (ereg($siteURL, $htmlString)) { echo "Yes"; } else { echo "No"; } ?> <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>[/php]

It only checks the first entry in the db for some reason so its back to scouring php.net

sorted it, had $partnersURL=$row_Recordset1[‘recip_url’]; outside the repeat

Sponsor our Newsletter | Privacy Policy | Terms of Service