Gossamer Forum
Quote Reply
Add links via script
Hi there Smile,

I am trying to add links to a Links table using the following code


Code:
$linkstbl->add({'CatLinks.CategoryID' => $new_cat_id,
Title => $diveshop->{name},
URL => "http://",
street => $diveshop->{street},
lat => $gps[0],
lng => $gps[1],
zipcode => $diveshop->{zipcode},
phone => $diveshop->{phone},
fax => $diveshop->{fax},
Contact_Email => $diveshop->{email} }) or print $diveshop->{name}." failed to import: ".$GT::SQL::error."\n";

Needless to say, the script croaked with the following message


Code:
Content-type: text/html

<h1>Software error:</h1>
<pre>GT::SQL::Table (14311): Wrong argument passed to this subroutine. $obj-&gt;insert(HASH or HASH_REF or CGI)
only. at /var/home/d4drtools/d4dr-tools.com/www/diveshopdemo/mycgi/admin/Links/Table/Links.pm line 37.
</pre>
<p>
For help, please send mail to this site's webmaster, giving this error message
and the time and date of the error.

</p>
[Fri Feb 27 05:31:01 2009] importdiveshops.cgi: GT::SQL::Table (14311): Wrong argument passed to this subroutine. $obj->insert(HASH or HASH_REF
or CGI) only. at /var/home/d4drtools/d4dr-tools.com/www/diveshopdemo/mycgi/admin/Links/Table/Links.pm line 37.
Thing is, I think it is time for me to learn what the differences between a hash and a hash_ref are. Since ,apparently, I can't seem to create
one properly. Or if some-one understand what I did wrong in this specific hash/hash_ref (???), please share your knowledge with me Smile

Thanks,
Happy weekend Laugh


Sacrifice is not about what you lose,
it is about what you gain in the process.
Quote Reply
Re: [EZFrag] Add links via script In reply to
This should do the trick:

Code:
my $add;
$add->{'CatLinks.CategoryID'} = $new_cat_id;
$add->{Title} = $title;
$add->{URL} = $url;

$DB->table('CatLinks','Links')->add($add) || die $GT::SQL::error;

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] Add links via script In reply to
Thanks Andy,

That worked great.

^_^


Sacrifice is not about what you lose,
it is about what you gain in the process.