Problem to reciprocal link checker (Curl & file_get_contents)

Hello
I check tow way, Curl and file_get_contents. Curl is hard and file_get_contents is normal.
First way Curl: article linke : http://www.merchantos.com/makebeta/p...inks-with-php/
This way have a problem:

Error, insert query failed

<?php   
//connect to database  
$hostname = 'localhost';   
$dbname   = 'newdb';   
$username = 'root';     
$password = '';      

// Let's connect to host  
mysql_connect($hostname, $username, $password) or DIE('Connection to host is failed, perhaps the service is down!');  
// Select the database  
mysql_select_db($dbname) or DIE('Database name is not available!');  
//get post value  
$titel=$_POST['titel'];  
$ural=$_POST['ural'];  
$page_linkus=$_POST['page_linkus'];  
$exposition=$_POST['exposition'];  
//------------------------  
function storeLink($titel,$ural,$ural,$ural) {  
    $query = "INSERT INTO links (titel, ural, page_linkus, exposition,) VALUES ('$titel', '$ural' ,'$page_linkus', '$exposition')";   
    mysql_query($query) or die('Error, insert query failed'); 
}  

$target_url = "http://www.merchantos.com/";  
$userAgent = 'Googlebot/2.1 (http://www.googlebot.com/bot.html)';  

// make the cURL request to $target_url  
$ch = curl_init();  
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);  
curl_setopt($ch, CURLOPT_URL,$target_url);  
curl_setopt($ch, CURLOPT_FAILONERROR, true);  
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);  
curl_setopt($ch, CURLOPT_AUTOREFERER, true);  
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);  
curl_setopt($ch, CURLOPT_TIMEOUT, 10);  
$html= curl_exec($ch);  
if (!$html) {  
    echo "<br />cURL error number:" .curl_errno($ch);  
    echo "<br />cURL error:" . curl_error($ch);  
    exit;  
}  

// parse the html into a DOMDocument  
$dom = new DOMDocument();  
@$dom->loadHTML($html);  

// grab all the on the page  
$xpath = new DOMXPath($dom);  
$hrefs = $xpath->evaluate("/html/body//a");  

for ($i = 0; $i < $hrefs->length; $i++) {  
    $href = $hrefs->item($i);  
    $url = $href->getAttribute('href');  
    storeLink($titel,$ural,$ural,$ural);  
    echo "<br />Link stored: $url";  
}  
?>

Second way: use of file_get_contents. this way write myself:
Error:

Error, insert query failed
Warning: file_get_contents(www.com.com) [function.file-get-contents]: failed to open stream: No such file or directory in D:\xampp\htdocs\ est.php on line 20
The string ‘http://www.sloo.com’ was not found in the string ‘’

<?php  
//connect to database  
$hostname = 'localhost';        // Your MySQL hostname. Usualy named as 'localhost', so you're NOT necessary to change this even this script has already online on the internet.  
$dbname   = 'newdb'; // Your database name.  
$username = 'root';             // Your database username.  
$password = '';                 // Your database password. If your database has no password, leave it empty.  

// Let's connect to host  
mysql_connect($hostname, $username, $password) or DIE('Connection to host is failed, perhaps the service is down!');  
// Select the database  
mysql_select_db($dbname) or DIE('Database name is not available!');  

//get post value  
$titel=$_POST['titel'];  
$ural=$_POST['ural'];  
$page_linkus=$_POST['page_linkus'];  
$exposition=$_POST['exposition'];  

$query = "INSERT INTO links (titel, ural, page_linkus, exposition,) VALUES ('$titel', '$ural' ,'$page_linkus', '$exposition')";   
    mysql_query($query) or die('Error, insert query failed'); 

//get contents $ural (.e.g $ural=www.hello.com)  
$get = file_get_contents($ural);  
//find $find to $get  
$find = 'http://www.sloo.com';  
$pos = strpos($get, $find);  

if ($pos === false) {  
    echo "The string '$find' was not found in the string '$get'";  
} else {  
    echo "The string '$find' was found in the string '$get'";  
    echo " and exists at position $pos";  
}  
?>

Pelse help me for obviation error!?
Which way is best?

Your MySQL query has an error in it, the error message your script was giving you was telling you the source of the problem.

Note the error in quotes “,”

$query = "INSERT INTO links (titel, ural, page_linkus, exposition",") VALUES ('$titel', '$ural' ,'$page_linkus', '$exposition')";

Your code should be

$query = "INSERT INTO links (titel, ural, page_linkus,  exposition) VALUES ('$titel', '$ural' ,'$page_linkus',  '$exposition')";

ok, thank
Why the function preg_match Slash does not accept?
Example:
does not accept: www.zigweb.ir/design
accept: www.zigweb.ir\/design
what to do?

function preg_match () is best or stripos ()?

If you need to match a string to a specific value then preg_match is the way to go, the reason why using www.zigweb.ir/design doesn’t work is because regular expressions sees that as been a standard expression rule where as \/ is saying that the forward slash is not a rule but part of the string

thank
What can I do to work preg_match with slash?
preg_match is best or stripos ?

If you need to check a URL for instance you can use str_replace to change the normal / to \/ like this

$string = str_replace('/', '\\/', $url);

Thank
How to convert the code below to Ajax or jQuery?
Ajax or jQuery as the existence of links be investigated. => reciprocal link checker Ajax or jQuery validation


		$string = str_replace('/', '\\/', $ural);
		$link = "/$string/si";
		if(preg_match($link, $contents)) {
			echo "yes";
		} else
		echo "no";
		}

$.[B]ajax/B - http://api.jquery.com/jQuery.ajax/

Docs - http://api.jquery.com/category/ajax/