Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

Dublicate checking upon adding

Quote Reply
Dublicate checking upon adding
hi there
i have tried the following code in add.cgi to prevent dublicate additions to the database.

# Check for duplicates..
my $url = $in->param('URL');
my $sth = $val->prepare ("SELECT ID FROM Links WHERE URL LIKE '$url_'");
$sth->execute();
if ($sth->rows) {
if ($in->param('CategoryID')) {
$name = &get_category_name ($in->param('CategoryID'));
$category = "$name <input type=hidden name='CategoryID' value='" . $in->param('CategoryID') . "'>";
}
else {
$category = &get_category_list();
}
return &site_html_add_failure( { error => "Duplicate URL",Category => $category, %in }, $dynamic);
}
The proble i am getting an error message upon callinbg add.cgi:
Software error:
Execution of add.cgi aborted due to compilation errors.

Can someone check it and tell me what is wrong?
Thanks

Abdoulrahman
Quote Reply
Re: Dublicate checking upon adding In reply to
qango posted codes for checking duplicate links, which I edited two weeks ago in this forum. Uses less codes than what you have written. Simply using query function in DBSQL will do a better job as well.

Regards,

Eliot Lee
Quote Reply
Re: Dublicate checking upon adding In reply to
katabd,

The thread is here:

http://www.gossamer-threads.com/...ew=&sb=&vc=1

All the best
Shaun

Quote Reply
Re: Dublicate checking upon adding In reply to
thanks qango
I already tried your hack then eliot hack and neither one seems to work for me.
I was able to add the same URl several times after each hack.
I trible checked each step, i could not figure it out.
i will quit for tonight i think.
thanks a lot thou

Regards

Abdoulrahman
Quote Reply
Re: Dublicate checking upon adding In reply to
The codes I posted DO work and SHOULD be posted in the sub process_form routine in the add.cgi script!

Regards,

Eliot Lee
Quote Reply
Re: Dublicate checking upon adding In reply to
The codes You posted DO not work for me also it might work for someone else, I did post the following code in the sub process_form routine in the add.cgi script:
------------------------------------------------------------
# Check that the record hasn't been added already in the Links and Validate tables.$val = new Links::DBSQL $LINKS{admin_root_path} . "/defs/Validate.def";$val->query ( { Description => $in->param('Description'), URL => $in->param('URL'), Title => $in->param('Title'), ww => 1 } );$db = new Links::DBSQL $LINKS{admin_root_path} . "/defs/Links.def";$db->query ( { Description => $in->param('Description'), Title => $in->param('Title'), URL => $in->param('URL'), ww => 1 } );if (($db->hits) and ($val->hits)) { &site_html_error ( { error => "A request to add this record has been received. We will notify you via email when your link has been validated."}, $dynamic);return;}if ($db->hits) { &site_html_error ( { error => "Your link already exists in our database. To modify your link, please click on the Edit Link link located at the top and bottom of our web pages."}, $dynamic);return;}if ($val->hits) { &site_html_error ( { error => "A request to add this record has been received and your link has not been validated yet."}, $dynamic);return;}

----------------------------------------------------------
Sorry man but if it did work I will not tell otherwise.
You can try it here:
http://www.idleb.com/cgi-bin/links/add.cgi

regards


Abdoulrahman
Quote Reply
Re: Dublicate checking upon adding In reply to
Katabd,

What happened when you tried eliots hack? What error's did you get, if any? Did it accept the duplicate?

A little more info might help us find out why it isn't working for you Smile

If you could post a copy of your add.cgi file after you've updated it with eliots hack then we may be able to help pin-point possible problem/s.

All the best
Shaun