Hi,
A better solution would be to simply use the fetchrow_hashref() method.
i.e.:
while(my $ref = $sth->fetchrow_hashref()){
print "$ref->{my_column}\n";
}
Much cleaner and easier to manage.
etc.
I've found this way much easier to manage than a huge list of variables.
Sven Bentlage wrote:
>
> Hi guys,
> just found a way that works, though it's not very elegant. (see below)
> and I do not know why it didn't work...
> Although it's working now, I'd still appreciate your comments.
>
> Regards,
> Sven
>
> code:
>
> while ( my (
> $u_id, $u_surname, $u_name, $u_rank, $u_cname, $u_caddress, $u_ctel,
> $u_cfax, $u_cmobile, $u_cemail, $u_curl, $u_btype, $u_hq,
> $u_quali, $u_experi, $u_inhouse, $u_resid, $u_ptel,$u_pfax,
> $u_pmobile,
> $u_pemail, $u_birthday, $u_marital, $u_spouse, $u_children_number,
> $u_children_names, $u_hobbies, $u_membership, $u_pcont,
> $u_permtel, $u_permfax, $u_course, $u_nation, $u_lastup, $u_loginid,
> $u_password, $u_japan_row, $u_ETPA_membership_paid,
> $u_ETPA_membership_expires,
> $u_face
> ) = $sth->fetchrow_array ) {...};
>
> On Wednesday, May 15, 2002, at 12:18 PM, Sven Bentlage wrote:
>
> > Hi!
> > I'm using the code below to fetch data from mysql, but when I print iit
> > out, several variables are always mixed up.
> > For example $u_course has the value of membership_paid, membership has
> > the values of pcont.
> >
> > Can anybody help me figure out how to correct that?
> >
> >
> > Thank you for your help.
> >
> > sven
> > code:
> > my $sth = $dbh->prepare(
> > "select *
> > from memberscopy
> > where name = '$f_name' and surname = '$f_surname' "
> > );
> >
> >
> > $sth->execute;
> >
> > #combine perl variables with data
> >
> > $sth->bind_col(1, \$u_id );
> > $sth->bind_col(2, \$u_surname);
> > $sth->bind_col(3, \$u_name);
> > $sth->bind_col(4, \$u_rank);
> > $sth->bind_col(5, \$u_cname);
> > $sth->bind_col(6, \$u_caddress);
> > $sth->bind_col(7, \$u_ctel);
> > $sth->bind_col(8, \$u_cfax);
> > $sth->bind_col(9, \$u_cmobile);
> > $sth->bind_col(10, \$u_cemail);
> > $sth->bind_col(11, \$u_curl);
> > $sth->bind_col(12, \$u_btype);
> > $sth->bind_col(13, \$u_hq);
> > $sth->bind_col(14, \$u_quali);
> > $sth->bind_col(15, \$u_experi);
> > $sth->bind_col(17, \$u_inhouse);
> > $sth->bind_col(18, \$u_resid);
> > $sth->bind_col(19, \$u_ptel);
> > $sth->bind_col(20, \$u_pfax);
> > $sth->bind_col(21, \$u_pmobile);
> > $sth->bind_col(22, \$u_pemail);
> > $sth->bind_col(23, \$u_birthday);
> > $sth->bind_col(24, \$u_marital);
> > $sth->bind_col(25, \$u_spouse);
> > $sth->bind_col(26, \$u_children_number);
> > $sth->bind_col(27, \$u_children_names);
> > $sth->bind_col(28, \$u_hobbies);
> > $sth->bind_col(29, \$u_membership);
> > $sth->bind_col(30, \$u_pcont);
> > $sth->bind_col(31, \$u_permtel);
> > $sth->bind_col(32, \$u_permfax);
> > $sth->bind_col(33, \$u_nation);
> > $sth->bind_col(34, \$u_course);
> > $sth->bind_col(35, \$u_loginid);
> > $sth->bind_col(36, \$u_japan_row);
> > $sth->bind_col(37, \$u_password);
> > $sth->bind_col(38, \$u_lastup);
> > $sth->bind_col(39, \$u_ETPA_membership_paid);
> > $sth->bind_col(40, \$u_ETPA_membership_expires);
> >
> > table structure:
> >
> >
> >
> > CREATE TABLE memberscopy (
> > id int(6) default NULL,
> > surname text,
> > name varchar(50) default NULL,
> > rank text,
> > cname text,
> > caddress text,
> > ctel text,
> > cfax text,
> > cmobile text,
> > cemail text,
> > curl text,
> > btype text,
> > hq text,
> > quali text,
> > experi text,
> > inhouse text,
> > resid text,
> > ptel text,
> > pfax text,
> > pmobile text,
> > pemail text,
> > birthday text,
> > marital text,
> > spouse varchar(150) default NULL,
> > children_number varchar(150) default NULL,
> > children_names varchar(150) default NULL,
> > hobbies text,
> > membership text,
> > pcont text,
> > permtel text,
> > permfax text,
> > course int(3) default NULL,
> > nation varchar(40) default NULL,
> > lastup year(4) default NULL,
> > loginid text,
> > password text,
> > japan_row set('jjj','rrr') default NULL,
> > ETPA_membership_paid date default NULL,
> > ETPA_membership_expires date default NULL,
> > face blob,
> > KEY id (id),
> > FULLTEXT KEY resid (resid)
> > ) TYPE=MyISAM;
> >
> >
> > ---------------------------------------------------------------------
> > Before posting, please check:
> > http://www.mysql.com/manual.php (the manual)
> > http://lists.mysql.com/ (the list archive)
> >
> > To request this thread, e-mail <[EMAIL PROTECTED]>
> > To unsubscribe, e-mail <mysql-unsubscribe-
> > [EMAIL PROTECTED]>
> > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
> >
> >
>
> ---------------------------------------------------------------------
> Before posting, please check:
> http://www.mysql.com/manual.php (the manual)
> http://lists.mysql.com/ (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail <[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
--
Colin Faber
(303) 736-5160
fpsn.net, Inc.
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php