I have such a database:
database name: link
| ID | Username LinkerM | Linkural | | 1 | [COLOR = "# FF0000"] one [/ COLOR] | | Google | Google.com | | 2 | [COLOR = "# FF0000"] one [/ COLOR] | | Yahoo | Yahoo dot | | 3 | [COLOR = "# 0000ff"] c [/ COLOR] | | Google2 | Google.com | | 4 | D | Ask | Ask.com |
When my user wants to add a new link, then I want to check the duplicate link. For example, if my user wants to add google.com then my php code has an error printing This link is a duplicate link. I have to link google.com to my database, I have no problem with this item, but I do not want any other google.com user.
I have written this code but not working:
$ oldlink = mysql_query ("select 'link' from COUNT (linker) where` username '= A and 'linkerl = google.com "); If ($ oldlink> 0) {echo 'duplicate link';} and {echo 'link submit';}
please help me.
Thank you.
The first mysql_query function will return a resource type, so your decision is wrong. View Php Manual
http://php.net/manual/en/function.mysql-db-query.php
In your case you get results There is a need to use mysql_fetch_assoc or mysql_fetch_row to process.
$ row = mysql_fetch_assoc ($ oldlink); // or $ row1 = mysql_fetch_row ($ oldlink);
At the same time suggest that if you use mysql_fetch_assoc, give your surname (COUNT) the nickname.
mysql_query ("SELECT COUNT (linkurl) linkurl as` link` where 'username' = an AND` linkurl` = google.com ");
No comments:
Post a Comment