use strict; use DBI; my $h = DBI->connect('dbi:mysql:database=test', "xxx", "yyy"); eval { $h->do(q/drop table CUSTOMER_PLAN/); }; $h->do(<do(q/INSERT INTO `CUSTOMER_PLAN` VALUES(1, 'Free', 0, 0.00, 0.75, 'A', '001', 'Try us out - receive 3 free recipes.')/); $h->do(q/INSERT INTO `CUSTOMER_PLAN` VALUES(2, 'Shine', 12, 9.75, 0.75, 'A', '002', 'Shine with a small introduction to Vibrant Healthy Living.')/); $h->do(q|INSERT INTO `CUSTOMER_PLAN` VALUES(3, 'Seeker', 35, 18.75, 0.75, 'A', '003', '-noun. An adventurous person who is seeking new experiences and new information to create a higher level of understanding and enlightenment.')|); $h->do(q|INSERT INTO `CUSTOMER_PLAN` VALUES(4, 'Sage', 60, 47.00, 0.75, 'A', '004', '-noun. A generous, lively person on the journey for the possession of wisdom and experience. This person is energetic, vibrant and famed for health and wisdom.')|); $h->do(q|INSERT INTO `CUSTOMER_PLAN` VALUES(5, 'Guru', 120, 89.00, 0.75, 'A', '005', '-noun. A divine teacher. This person has vast knowledge and practices vibrant living while sharing with their community to create a greater understanding and manifestation of truth and beauty.')|); sub db_err { my ($pmsg, $psql, $perrnum, $perrstr) = @_; print "

There was a problem: $pmsg.

\n"; print "

Attempted command: $psql

\n"; print "

Error: $perrnum - $perrstr

\n"; } my $dbname = 'test'; my $planname = 'Free'; my $sql = "SELECT DCredits, Price, Description FROM $dbname.CUSTOMER_PLAN WHERE Name='$planname'"; my $sqlh = $h->prepare($sql) || db_err("preparing statement handle", $sql, $DBI::err, $DBI::errstr); $sqlh->execute || db_err("executing query", $sql, $DBI::err, $DBI::errstr); #####while (@row = $sqlh->fetchrow_array()) #####{ ##### ($credits, $price, $descript) = @row; ##### # process the data on each loop here #####} #####$sqlh->finish; $h->disconnect; #### DBD::mysql::st execute failed: Unknown column 'DCredits' in 'field list' at /home/martin/930402.pl line 45.

There was a problem: executing query.

Attempted command: SELECT DCredits, Price, Description FROM test.CUSTOMER_PLAN WHERE Name='Free'

Error: 1054 - Unknown column 'DCredits' in 'field list'

##
## -> prepare for DBD::mysql::db (DBI::db=HASH(0x9f482a0)~0x9f483c0 'SELECT DCredits, Price, Description FROM test.CUSTOMER_PLAN WHERE Name='Free'') thr#9dd4008 New 'DBI::st' (for DBD::mysql::st, parent=DBI::db=HASH(0x9f483c0), id=undef) dbih_setup_handle(DBI::st=HASH(0x9f48180)=>DBI::st=HASH(0x9e50408), DBD::mysql::st, 9ece010, Null!) dbih_make_com(DBI::db=HASH(0x9f483c0), 9f3e808, DBD::mysql::st, 252, 0) thr#9dd4008 dbih_setup_attrib(DBI::st=HASH(0x9e50408), Err, DBI::db=HASH(0x9f483c0)) SCALAR(0x9ecdf30) (already defined) dbih_setup_attrib(DBI::st=HASH(0x9e50408), State, DBI::db=HASH(0x9f483c0)) SCALAR(0x9ecdfb0) (already defined) dbih_setup_attrib(DBI::st=HASH(0x9e50408), Errstr, DBI::db=HASH(0x9f483c0)) SCALAR(0x9ecdf70) (already defined) dbih_setup_attrib(DBI::st=HASH(0x9e50408), TraceLevel, DBI::db=HASH(0x9f483c0)) 0 (already defined) dbih_setup_attrib(DBI::st=HASH(0x9e50408), FetchHashKeyName, DBI::db=HASH(0x9f483c0)) 'NAME' (already defined) dbih_setup_attrib(DBI::st=HASH(0x9e50408), HandleSetErr, DBI::db=HASH(0x9f483c0)) undef (not defined) dbih_setup_attrib(DBI::st=HASH(0x9e50408), HandleError, DBI::db=HASH(0x9f483c0)) undef (not defined) dbih_setup_attrib(DBI::st=HASH(0x9e50408), ReadOnly, DBI::db=HASH(0x9f483c0)) undef (not defined) dbih_setup_attrib(DBI::st=HASH(0x9e50408), Profile, DBI::db=HASH(0x9f483c0)) undef (not defined) -> dbd_st_prepare MYSQL_VERSION_ID 50083, SQL statement: SELECT DCredits, Price, Description FROM test.CUSTOMER_PLAN WHERE Name='Free' >- dbd_st_free_result_sets <- dbd_st_free_result_sets RC -1 <- dbd_st_free_result_sets >count_params statement SELECT DCredits, Price, Description FROM test.CUSTOMER_PLAN WHERE Name='Free' <- dbd_st_prepare <- prepare= DBI::st=HASH(0x9f48180) at /home/martin/930402.pl line 44 >> execute DISPATCH (DBI::st=HASH(0x9f48180) rc1/1 @1 g0 ima1041 pid#19440) at /home/martin/930402.pl line 45 -> execute for DBD::mysql::st (DBI::st=HASH(0x9f48180)~0x9e50408) thr#9dd4008 -> dbd_st_execute for 09ece030 >- dbd_st_free_result_sets <- dbd_st_free_result_sets RC -1 <- dbd_st_free_result_sets mysql_st_internal_execute MYSQL_VERSION_ID 50083 >parse_params statement SELECT DCredits, Price, Description FROM test.CUSTOMER_PLAN WHERE Name='Free' --> do_error Unknown column 'DCredits' in 'field list' error 1054 recorded: Unknown column 'DCredits' in 'field list' <-- do_error IGNORING ERROR errno 0 <- dbd_st_execute returning imp_sth->row_num 18446744073709551614 !! ERROR: 1054 'Unknown column 'DCredits' in 'field list'' (err#0) <- execute= undef at /home/martin/930402.pl line 45 DBD::mysql::st execute failed: Unknown column 'DCredits' in 'field list' at /home/martin/930402.pl line 45. -> $DBI::err (*) FETCH from lasth=HASH <- $DBI::err= 1054 -> $DBI::errstr (&) FETCH from lasth=HASH >> DBD::mysql::st::errstr <- $DBI::errstr= 'Unknown column 'DCredits' in 'field list''