Gossamer Forum
Home : Products : Gossamer Links : Discussions :

updating bad link table

Quote Reply
updating bad link table
Hello,

I have created a new column in my bad_link table named 'REASON'. I set the type to varchar(150) and NULL to 'yes'.

Then in my bad_link.html I added the following:

<select name="REASON" size="4" multiple>
<option value="Link doesn't work">Link doesn't work</option>
<option value="Site is overly misleading">Site is overly misleading</option>
<option value="Site tries to send viruses">Site tries to send viruses</option>
<option value="Illegal content">Illegal content</option>
</select>

I also modified the bad_link report so that the column for REASON shows up. Now on to my question :)

How do I pass the reasons into the REASON column in the bad_link table? I think it is handled by bad_link.cgi. I tried this:

$db_bad_links->add ( { LinkID => $id,
REASON => $rec->{'REASON'}
URL => $rec->{'URL'},
Title => $rec->{'Title'},
IP => $ENV{'REMOTE_ADDR'}
} );

But, that doesn't work. I don't know what that section means, I was just taking a random guess. If I manually input a reason using mysqlman then the reason does show up on my bad link report. I just can't figure out how to pass the value from my html form into MYSQL.

I really did try to figure this out on my own, but is beyond me. Any help would be most appreciated!!
Quote Reply
Re: [Demolitioncrew] updating bad link table In reply to
Haven't given this much thought but it might be as simple as a missing comma:

REASON => $rec->{'REASON'},
Quote Reply
Re: [afinlr] updating bad link table In reply to
Thanks, I'm sure that is something that would have cropped up to haunt me, but it didn't actually seem to fix the particular issue. Thanks!
Quote Reply
Re: [Demolitioncrew] updating bad link table In reply to
OK, giving this a bit more thought (Tongue) without taking a look at the script my guess would be that in your form you are passing in the ID of the link and then looking this up in the links table. So the $rec values are the ones that you have looked up. Obviously, the REASON column isn't in the Links table, it is being passed into the script along with the ID. I would think you need to change $rec to $IN?

REASON => $IN->{'REASON'}
Quote Reply
Re: [afinlr] updating bad link table In reply to
Well it doesn't give me an error Angelic. However, it doesn't seem to do the trick either.

Again...thanks for your attempts to help!
Quote Reply
Re: [Demolitioncrew] updating bad link table In reply to
Oops Blush try this

REASON => $IN->param('REASON'),
Quote Reply
Re: [afinlr] updating bad link table In reply to
i would like to report that you are my new best friend...even though it DID NOT work. It's still not writing a value to the REASON column for some reason.
Quote Reply
Re: [Demolitioncrew] updating bad link table In reply to
Try:

REASON => scalar $IN->param('REASON'),

....if that doesn't work there is something amiss in some of your other code.
Quote Reply
Re: [Paul] updating bad link table In reply to
It must be elsewhere in the code as that doesn't work either. I changed my column specs for the REASON field to Enum and set the fields so that would match exactly, but that didn't do it either. Can you think of a section of the code I should provide here to make it more clear as to what I am doing incorrectly?
Quote Reply
Re: [Demolitioncrew] updating bad link table In reply to
This is weird.... I was taking a shower and for some reason thought of looking into adding this same thing. Sat down to read some threads before I got to work and here it was.

Using the info you people have provided I made all the needed changes but ended up with the same problem. For some strange reason the script won't add the "Reason" values to the bad_link table. I've tried everthing I can think of over and over again. Even went through other plugins and just don't see a reason why the data Isn't being added. Even tried to resync and Repair along the way to see if that did something.

Here's what I've got at this point...

(Bad_Link Table: Reason)

sub main {

# Define the variables
# ---------------------------------------------------
my ($id, $db_links, $rec, $confirm, $reason);

# Get the Links ID number from the input.
$id = $IN->param('ID');
$confirm = $IN->param('confirm');
$reason = scalar $IN->param('Reason');

...

$db_bad_links->add ( { LinkID => $id,
URL => $rec->{'URL'},
Title => $rec->{'Title'},
IP => $ENV{'REMOTE_ADDR'},
Reason => $reason
} );



I just don't understand why this doesn't work. Hopefully someone will see where the problem is. Being able to let users submit a reason along with the report would be a great mod to Pugdogs useful plug.

-DemolitionCrew- Good work with your site man, I was just checking it out the other day. Would you mind me asking you a quick question about something you using on your site? If not, I'll send you an e-mail or PM sometime soon.

Last edited by:

Jonze: Mar 20, 2003, 10:15 PM
Quote Reply
Re: [Jonze] updating bad link table In reply to
Sure Jonze...hit me up :)
Quote Reply
Re: [Demolitioncrew] updating bad link table In reply to
coolio! Wink Check your PM in a few.
Quote Reply
Re: [Jonze] updating bad link table In reply to
If it is adding the rest of the record to the table (i.e. adding a record with a blank value for Reason) then all I can think is that the Reason variable is not being passed to the script.

Try calling the script from your browser using bad_link.cgi?ID=1&confirm=yes&Reason=test

using a valid ID and whatever the confirm variable should be to run the script.

If this works then there must be something wrong with your form.
Quote Reply
Re: [afinlr] updating bad link table In reply to
Yeah, It's adding the rest of the record just fine except, all of the Reason fields are being left blank. I've just been trying to call the script via the browser like you said and still nothing is being added.

bad_link.cgi?ID=1&confirm=confirm&Reason=test

Everything goes through fine except for that reason value. I don't know, I'm stumped. Guess I'll look around some more.

Thanks for your help though!
Quote Reply
Re: [Jonze] updating bad link table In reply to
Try putting double quotes round $reason in the add statement. This may sound strange but I (and others) have found that this sometimes fixes problems in update statements - no idea why - but worth trying since everything else seems ok.
Quote Reply
Re: [afinlr] updating bad link table In reply to
Wooho! Sly

I just found the problem

The Bad_Links.def file wasn't being updated. I forgot it was using that so I had to add in the new field properties manualy...

'Reason' => {
'form_size' => '30',
'form_type' => 'TEXT',
'not_null' => '1',
'pos' => '7',
'size' => '150',
'type' => 'VARCHAR'
}

Everythings bad link reports are working great now. Sometimes a little sleep goes a long way.

Here's the rest of the bad_link.cgi changes that got it working:

# Define the variables
# ---------------------------------------------------
my ($id, $db_links, $rec, $confirm, $reason);

# Get the Links ID number from the input.
$id = $IN->param('ID');
$confirm = $IN->param('confirm');
$reason = $IN->param('Reason');

...

$db_bad_links->add ( { LinkID => $id,
URL => $rec->{'URL'},
Title => $rec->{'Title'},
IP => $ENV{'REMOTE_ADDR'},
Reason => $reason
} );


I think that should solve your problem as well DemolitionCrew. Thanks for you help everybody! Some nice info to know.

Later
Quote Reply
Re: [Jonze] updating bad link table In reply to
Hi,

Was that the problem :) I was going to ask about that (updated .def file, but you did say you resync'd??).

How did you create the new column in the BadLink table? If you add a column through the admin->properties area, you'll update the .def files properly. If you add the column through MySQLMan or some other manner, if you resync, you should update the .def file.

I'm *really* curious about this, since I'm updating the plugins, and tracking all quirks from older versions, and changes to newer versions of Links.

I can add this into the base code, if people don't mind :)


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] updating bad link table In reply to
Hi Pugdog,

Yeah, I tried to resync the definition files many times while trying to get this to work. I added the new column via MySQLMan. I had thought the definitions would have been updated but that doesn't seem to be the case.

Sure I'd like to see this added in an update. I was also looking at making the plug send a simple e-mail to the admin via template. Was just looking at other plugins and it seems to be pretty simple. I don't know if you would want to consider that or not. If not I could try to give it a go here soon and send you the code if all goes well. Maybe you could add that to a future update as well. It would be nice to be notified as soon as an error is reported. Just let me know.

Thanks again for the useful plug =)
Quote Reply
Re: [Jonze] updating bad link table In reply to
Quote:
Sure I'd like to see this added in an update.

It is there, you are just adding the columns the wrong way :)

You should be adding them via the table editor in the admin panel which makes all the necessary def updates for you.
Quote Reply
Re: [Paul] updating bad link table In reply to
I just incorporated the "reason" column described in this thread, since it's a feature I also wanted.

To add a new column to the bad_link table I used MySQLMan. The only tables available in the Admin>Database>Editor section are Category, Links, Users and Reviews. Is there a way to have the editor show other tables?

Am I missing something or looking in the wrong place?

Thanks
ronzo
Quote Reply
Re: [ronzo] updating bad link table In reply to
You can add tables to the select list if you want, or use the URL eg:

admin.cgi?db=Editors&do=editor_table_form

...that would load the editors table.
Quote Reply
Re: [Paul] updating bad link table In reply to
Thanks Paul,

admin.cgi?db=Bad_Link&do=editor_table_form

works great for loading the Bad_Link table into the editor from the URL.

Also, adding Bad_Link to the select list in db_nav.html (admin/templates/admin) does the trick.

I'll definitely get into the habit of altering tables this way.

Thanks again Paul, and thanks Jonze for coming up with a solution.

ronzo

Last edited by:

ronzo: Mar 21, 2003, 5:13 PM
Quote Reply
Re: [ronzo] updating bad link table In reply to
Hi,

The way I do it, since I can't remember that url, is to load the properties feature of one of the main tables, and then right click on the edit that table command, and open in a new window. That shows the URL, and then I just change the db= parameter to what I want, and hit enter. Works like a charm :)

There was a simple hack to the admin script to show all tables, for 1.1x, I don't know if it works in 2.x but I'll check. Might be able to be a simple plugin. Just list all the tables in a drop down box :)


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.