Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Update... why this error though? :/

Quote Reply
Update... why this error though? :/
Hi guys/gals,

I'm using the following line in one of my scripts;

$DB->table('Links')->update( { 'BeenChecked' => '1' } , { 'ID' => $hit->{ID} } ) || die $GT::SQL::error . $DB->query_stack_disp;

However, I keep getting the following error;

Quote:
<p><font face='Tahoma,Arial,Helvetica' size=2>A fatal error has occured:</font><
/p><blockquote><pre>The column 'LinkID' must be unique, and already has an entry
'145' at update.pl line 42.
</pre></blockquote><p><font face='Tahoma,Arial,Helvetica' size=2>Please enable d
ebugging in setup for more details.</font></p>
The column 'LinkID' must be unique, and already has an entry '145' at update.pl
line 42.

However, 145 is the LINK ID, and not the value that is meant to be set for "BeenChecked".

Basically, the query should look something like;

UPDATE lsql_Links SET BeenChecked = '1' WHERE ID = '145';

... but it looks more like its being structured as;

UPDATE lsql_Links SET ID = '145' WHERE BeenChecked = '1' ;

Anyone got any ideas? Unimpressed

TIA

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Update... why this error though? :/ In reply to
Well, I'm still not quite sure why it was doing what it was.... but at least its working now;

$DB->table('Links')->update($hit, { ID => $hit->{ID} }) || die $GT::SQL::error;

Yay Cool

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Update... why this error though? :/ In reply to
Eugh... still not working Unimpressed

$DB->table('Links')->update( { Pages => $pages }, { ID => $id }) || die $GT::SQL::error;

...gives;

Quote:
<p><font face='Tahoma,Arial,Helvetica' size=2>A fatal error has occured:</font><
/p><blockquote><pre>Need a file glob reference in (OriginalDocument) at update.p
l line 280.
</pre></blockquote><p><font face='Tahoma,Arial,Helvetica' size=2>Please enable d
ebugging in setup for more details.</font></p>
Need a file glob reference in (OriginalDocument) at update.pl line 280.

OriginalDocument is a FILE type, but that has never given me a problem before.

Anyone got any ideas? This is really getting on my nerves, as it seems to be doing the same on every update(). ... HELP!

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Update... why this error though? :/ In reply to
Eugh... STILL struggling with this one :(

Basically, I have this code;

Code:
my $hit = $DB->table('Links')->get($id);
$hit->{Words} = "$words";
$hit->{Paragraphs} = "$paragraphs";
$hit->{Pages} = "$pages";
$hit->{NumImages} = "$numimages";
$hit->{EditingTime} = "$editingtime";
#print "Stats: " . Dumper($hit);
print "Updating stats for: $id \n";
$DB->table('Links')->update( $hit, { ID => $id } ) || die $GT:SQL::error, Dumper($hit) . __LINE__;

Now, if I uncomment this line;

#print "Stats: " . Dumper($hit);

..it prints out a dump of the hashref, including "Words", "Pages" "Paragraphs" etc are ALL populated fine!

So, this means it **has** to be down to the update itself. But why?

Note: I've tried using a normal update, i.e;


$DB->table('Links')->update( { Words => $words, Paragraphs => $paragraphs} , { ID => $id } ) || die $GT:SQL::error, Dumper($hit);

... but that doesn't work at all (something about our OriginalFile field not being allowed to be blank, even though I didn't pass in a specific filename to change it too,... which is also very conusding :/

TIA

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Update... why this error though? :/ In reply to
Try:
Code:
$DB->table('Links')->modify( $hit ) || die $GT:SQL::error, Dumper($hit) . __LINE__;
May need to set the $hit->{ID} if it is missing from $hit.
But this should work.

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [webmaster33] Update... why this error though? :/ In reply to
Hi,

Thanks for the reply. First it gave me an error about the category ID not existing, so I fixed this up by adding in a couple more lines of code, to populate $hit->{'CatLinks.CategoryID'} , and then it **appeared** to have worked.

However, as soon as I go back into the database, its not there again :(

Guess I better keep looking Unsure

Thanks though :)

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [webmaster33] Update... why this error though? :/ In reply to
OMG.. think I've found it!

I added an;

Code:
exit;

after the update() command, and then checked the database entry, and it shows the right word count!!!! WAHOO!!!! Laugh

Now all I've gotta do, is go through the rest of the script (all 1500 lines of code :/), and try to track down where this last update is going on.. doh!

Smile

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Update... why this error though? :/ In reply to
Hehe. Smile
The exit; command was invisible in your quoted code. Wink
Glad you got it!

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [webmaster33] Update... why this error though? :/ In reply to
Hi,

Quote:
The exit; command was invisible in your quoted code.
Glad you got it!

That wasn't actually the problem :) I put that in, to stop it after the stats update. Then, I checked to see if the database had been updated (which is had), so that led me to believe there was another update being called in a different routine, which didn't have the "Words" or "Paragraphs" values. This was correct, and it works perfeclty now Cool

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!