Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Perl Programming Language

CGI mysql problem


Where to begin trouble shooting this?

The problem is that I have 17 entries in mysql database and when I run
my sub routine it only returns the entries that are not in the first
two rows.  I tried to update the first row, without result.  And I re-
entered  the first two rows to rows 18 and 19 and then they would be
entered in the feeds array.

I'm running mysql ver mysql-5.0.37-osx10.4-i686
apache 2.2;
Mac osx tiger

I check the scalar on the returned array and it always is two less
than what the db shows.

Thanks
mike

sub get_all_feeds {
    my $self = shift;
    my @args = @_;

    my $allfeed_sql = qq{
SELECT title, url, xml, date, feed_id
FROM rss_feeds
    };
    my $dbh = $self->{dbh};

    my $sth = $dbh->prepare($allfeed_sql) or die "Couldn't prepare:
" . $dbh->errstr;
    $sth->execute or die "Couldn't execute: " . $sth->errstr;
     my @tablefeeds = $sth->fetchrow_array;
    # is there already a row with this username?
    if (!$sth->fetchrow_array) {
        return 0;
    }

    my @feeds;
    while (my $row = $sth->fetchrow_hashref) {
        my $feed =
            Feeds::Feed->new_feed(title        => $row->{title},
                               url             => $row->{url},
                               xml             => $row->{xml},
                               date            => $row->{date},
                               feed_id         => $row->{feed_id});

        push (@feeds, $feed);
    }
    return @feeds;

mmccaws2 <mmcc@comcast.net> writes:
> The problem is that I have 17 entries in mysql database and when I run
> my sub routine it only returns the entries that are not in the first
> two rows.
>     my $sth = $dbh->prepare($allfeed_sql) or die "Couldn't prepare:
> " . $dbh->errstr;
>     $sth->execute or die "Couldn't execute: " . $sth->errstr;
>      my @tablefeeds = $sth->fetchrow_array;

Now the first row is in @tablefeeds.

>     # is there already a row with this username?
>     if (!$sth->fetchrow_array) {

You've fetched the second row and thrown it away.

>         return 0;
>     }

>     my @feeds;
>     while (my $row = $sth->fetchrow_hashref) {
>         my $feed =
>             Feeds::Feed->new_feed(title        => $row->{title},
>                                url             => $row->{url},
>                                xml             => $row->{xml},
>                                date            => $row->{date},
>                                feed_id         => $row->{feed_id});

>         push (@feeds, $feed);
>     }
>     return @feeds;

This loop puts the rest of the rows, starting with the third, in @feeds
and returns that.

sherm--

--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net

On May 29, 9:02 pm, Sherm Pendley <spamt@dot-app.org> wrote:

Fantastic.  I thought the while would start from scratch, but I see
that now.

Thanks

mike

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc