Jump to content

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


mikhak
Go to solution Solved by Barand,

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.
 
Link to comment
Share on other sites

"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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.