David,
You don't have a response set at execute. You have
a reference to a responce set. You need to use DBI
methods to access the results. Try this...
============================
$response->execute();
my $hash = {};
while (my $rows = $response->fetchrow_hashref){
$hash->{$rows->{task_ID}} = $rows;
}
$response->finish();
use Data::Dumper;
print Dumper $response;
============================
--- Greenhalgh David <[EMAIL PROTECTED]>
wrote:
> Hi all,
>
> I have a script which mostly works, but when I get
> to the part with
> hashes, it stops. I'm obviously doing something very
> basically wrong,
> but I can't see what. (been staring at so long it
> could be anything.) A
> segment of the code is below:
>
> #!/usr/local/perl -wT
> use strict;
> use CGI;
>
> # Do some stuff to identify the value of $marker
> which will be a number
>
> # Do MySQL query to grab the data to be manipulated
>
> my $dbh=connect(DBI:mysql:database, "user",
> "password");
> my $query=("SELECT task_ID, priority FROM task_list
> WHERE priority
> >$marker");
> my $reponse->prepare($query);
> $response->execute;
>
> # $ response should now contain a
> # reference to a hash filled with task_ID, priority
> pairs
> # Dereference $response
>
> my %hash=%($response);
> $response->finish;
>
> # Subtract 1 from each value in the hash
> my ($key, $priority, %newhash);
>
> foreach $key (keys(%hash)){
> my $priority=$hash{$key}--;
> %newhash=($key, $priority);
> }
>
> # Put the new $priority values into the MySQL table
>
> $query=("UPDATE task_list SET priority=? WHERE
> task_ID=?");
> $response->prepare($query);
>
> foreach $key (keys{%newhash}){
> $priority=$newhash{$key};
> $response->execute($priority, $key);
> }
>
> $response->finish;
>
> # Test the result
>
> print "Content-Type: text/html\n\n";
>
> $query=("SELECT" task_ID, priority FROM task_list");
> $response->prepare($query);
> $response->execute;
>
> while($key, $priority){
> print "Priority: $priority Task Ident:
> $key<br>\n\n";
> }
>
>
> Would someone be patient enough to point out the
> mistake?
>
> Thanks
>
> Dave
>
>
> --
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
>
=====
-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GIT d s+:++ a C++ UL++ US+ P+++ L++
W+++ w PS PE t++ b+ G e r+++ z++++
------END GEEK CODE BLOCK------
__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]