URL Verification

URL VerificationDo you have a big list of links in your database that you want to display but only want to show ones that are still in existance? Well theres a very easy method for doing so. All you need is the fsockopen() function. Here is an example:

<?
$testURL = @fsockopen("www.FreeTemplateDesigns.com", 80, $errno, $errstr, 30);
if($testURL)
{
echo "<a href="http://www.FreeTemplateDesigns.com">Free Template Designs</a>";
}
>?>

In this example you can see the fsocketopen() function being called as a test on the url. If it can connect to it, it exists and prints. Otherwise, nothing happens. now lets say you wanted to do this with a large list of links from your database. It's just as simple.

<?php
$link = mysql_connect('localhost', 'username', 'password');
mysql_select_db('database', $link);

$query = mysql_query("SELECT * FROM links");
while($row = mysql_fetch_array($query))
{
$testURL = @fsockopen("www.FreeTemplateDesigns.com", 80, $errno, $errstr, 30);
if($testURL)
{
echo "<a href="http://$row[url]">$row[name]</a><br>";
}
}
?>

Related Articles

  • Six Ways to Combat Online Fraud
    Credit card fraud. Its one of the biggest problems that eBusinesses face. The most effective means of deterring online credit card fraud are:
  • Google Local
    This tutorial will show a small business owner how to (1) set up a Google Local account (2) How to use Google Local (3) How to Manage Google Local (4) How to optimize your Google Local account.
  • More Adsense Traffic
    If youve been running AdSense ads on your site for quite a while and you feel that you arent making as much cash as you could, in 99.99% of cases youre right. Most people feel frustrated that they cannot generate the revenues they expected, and this is down to traffic levels as well as click t...
  • 7 Reasons You Should Avoid JavaScript Dynamic Navigation
    This informative article tells you 7 Reasons You Should Avoid JavaScript Dynamic Navigation. The author explains the technical reasons behind each of the 7, and provides excellent examples.
  • 7 Ways of Building Customers' Trust With Your Web Site
    Credibility lies at the heart of a fiscally healthy online business. Find out how to get it, and how to keep it, without making face to face contact with customers.
  • Social Media Optimisation - The Importance of an Avatar
    Social media has become an integral part of Search Engine Optimization, or SEO, over the past couple of years. It is widely regarded as an excellent way of promoting your website and increasing your brand awareness; building links into your site; and setting yourself up as an authority within your c...
  • Getting Web Site Traffic in Less Than One Day
    Every web site owner has wanted to drive additional traffic to their web site
  • Top Reasons Why You May Not Be Indexed
    At one time or another you may have used a submission tool, or submitted by hand and then wondered why you had not been indexed. Unfortunately, there are many re...
  • Read This Before you Submit to Web Directories
    This excellent article raises all the necessary questions that you should know about before submitting your website to web directories.
  • Be Aware of Phishing Scams!
    If you use emails actively in your communication, you must have received various messages claiming to be from eBay, PayPal and a number of banks. A recent email, as if from U.S. Bank Corporation, contains the subject

Contact Web Design Outsource and get started today

Need Website Designing, Development, Redesigning, Maintenance and SEO services or help growing your company's web presence? Request a free Quote Now.