Jump to content

how i can checking the duplicate links with php and mysql ?


mikhak

Recommended Posts

Hi

i have a database like this :

database name : link

id    username    linkterm    linkurl

1     a              google     google.com        

2     a              yahoo      yahoo.com

3     c               google2        google.com

4     d               ask         ask.com

i want checking the duplicate links when my user want adding new link . for example if my user want adding the google.com my php codes should printing a error that this link is duplicate links. i have to google.com links in my database i don't have any problem this item but i want don't have any other google.com in " a " user .

i wrote this code but not working :

$oldlink = mysql_query("SELECT COUNT(linkurl) FROM `link` where `username`=a AND `linkurl`=google.com");
if($oldlink>0){
echo 'duplicate links';
}
else{
echo 'links submitted';
}

please help me .


thank you.
 

"a" and "google.com" in the query need to be inside single quotes

 

SELECT COUNT(linkurl) FROM `link` where `username` = 'a' AND `linkurl` = 'google.com'

 

i tested this code but not working too i tested this code in run sql but not working.

 

thank you for helping

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.