Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple select crashes mysql output

Status
Not open for further replies.

rdb309

Programmer
Apr 17, 2003
1
US
Undeveloped development here. I am trying to fetchrow_array
for one row from table. It works fine and displays good
if $value is defined in perl script, but when input from
form (STDIN reads {exactly the same as defined input}, it
freezes up mysql. DBI trace shows it fetched the row but
it fails to finish its business in there and I get no
output. Follows is highlights of the coding:


<form method=&quot;POST&quot; action=&quot; Enter Member ID: <input type=&quot;text&quot; size=&quot;10&quot; name=&quot;mem_id&quot;>
<input type=&quot;submit&quot; value=&quot;submit&quot;>
</form>

That's from the form, and the name value pairs are separated
etc on the script, and I wind up with $value which is used
in the placeholder below in the statement from hell.


my $dbh = DBI->connect (&quot;DBI:mysql:mem_master&quot;, u & p omit)
or die (&quot;Cannot connect: DBI::errstr&quot;);



$sth = $dbh->prepare(&quot;SELECT * FROM members WHERE mem_id = ?&quot;) or die (&quot;Can't prepare: $sth->errstr\n&quot;);


$sth->execute($value) or die (&quot;can't execute: $sth->errstr\n&quot;);


while(@row = $sth->fetchrow_array()) {

Right there is where I find that the new life Jesus has
given me is extremely valuable .

Here's the trace info that comes from that run. And as I
said, it works fine if I define the $value, but it is
completely clean coming from the input page by the time I
get it to the execute statement. I'm not running in taint
mode, but at this point, I'm somewhat not ready since I
can't even figure out how to make it run period. Thanks so
much for any input.

Oh yes, the column name I'm using is the primary key out
of the table, and is also called mem_id, as is the name of
the input field, but the name get's separated from
the value.

DBI 1.30-ithread dispatch trace level set to 5
-> DBI->connect(DBI:mysql:mem_master, ****, ****)
-> DBI->install_driver(mysql) for MSWin32 perl=5.008 pid=84361695 ruid=0 euid=0
install_driver: DBD::mysql version 2.1026 loaded from C:/Perl/site/lib/DBD/mysql.pm
New DBI::dr (for DBD::mysql::dr, parent=, id=)
dbih_setup_handle(DBI::dr=HASH(0x1563fe8)=>DBI::dr=HASH(0x281e53c), DBD::mysql::dr, 0, Null!)
dbih_make_com(Null!, DBD::mysql::dr, 84) thr#155424c
dbih_setup_attrib(DBI::dr=HASH(0x281e53c), Err, Null!) SCALAR(0x155cbc8) (already defined)
dbih_setup_attrib(DBI::dr=HASH(0x281e53c), State, Null!) SCALAR(0x15641f4) (already defined)
dbih_setup_attrib(DBI::dr=HASH(0x281e53c), Errstr, Null!) SCALAR(0x155cbe0) (already defined)
dbih_setup_attrib(DBI::dr=HASH(0x281e53c), Debug, Null!) 0 (already defined)
dbih_setup_attrib(DBI::dr=HASH(0x281e53c), FetchHashKeyName, Null!) 'NAME' (already defined)
<- install_driver= DBI::dr=HASH(0x1563fe8)
-> default_user in DBD::_::dr for DBD::mysql::dr (DBI::dr=HASH(0x1563fe8)~0x281e53c 'rick' undef HASH(0x15dc738)) thr#155424c
<- default_user= ( 'rick' undef ) [2 items] at C:/Perl/site/lib/DBI.pm line 500 via c:\inetpub\ line 51
-> connect for DBD::mysql::dr (DBI::dr=HASH(0x1563fe8)~0x281e53c 'mem_master' 'rick' **** HASH(0x15dc738)) thr#155424c
New DBI::db (for DBD::mysql::db, parent=DBI::dr=HASH(0x281e53c), id=HASH(0x281e488))
dbih_setup_handle(DBI::db=HASH(0x281e500)=>DBI::db=HASH(0x281e5f0), DBD::mysql::db, 1563918, HASH(0x281e488))
dbih_make_com(DBI::dr=HASH(0x281e53c), DBD::mysql::db, 592) thr#155424c
dbih_setup_attrib(DBI::db=HASH(0x281e5f0), Err, DBI::dr=HASH(0x281e53c)) SCALAR(0x155cbc8) (already defined)
dbih_setup_attrib(DBI::db=HASH(0x281e5f0), State, DBI::dr=HASH(0x281e53c)) SCALAR(0x15641f4) (already defined)
dbih_setup_attrib(DBI::db=HASH(0x281e5f0), Errstr, DBI::dr=HASH(0x281e53c)) SCALAR(0x155cbe0) (already defined)
dbih_setup_attrib(DBI::db=HASH(0x281e5f0), Debug, DBI::dr=HASH(0x281e53c)) 0 (already defined)
dbih_setup_attrib(DBI::db=HASH(0x281e5f0), FetchHashKeyName, DBI::dr=HASH(0x281e53c)) 'NAME' (already defined)
dbih_setup_attrib(DBI::db=HASH(0x281e5f0), HandleError, DBI::dr=HASH(0x281e53c)) undef (not defined)
imp_dbh->connect: dsn = mem_master, uid = rick, pwd =
imp_dbh->MyLogin: dbname = mem_master, uid = rick, pwd = NULL,host = NULL, port = NULL
imp_dbh->mysql_dr_connect: host = NULL, port = 0, uid = rick, pwd = NULL
imp_dbh->mysql_dr_connect: client_flags = 0
imp_dbh->mysql_dr_connect: <- <- connect= DBI::db=HASH(0x281e500) at C:/Perl/site/lib/DBI.pm line 503 via c:\inetpub\ line 51
-> STORE for DBD::mysql::db (DBI::db=HASH(0x281e5f0)~INNER 'PrintError' 1) thr#155424c
STORE DBI::db=HASH(0x281e5f0) 'PrintError' => 1
<- STORE= 1 at C:/Perl/site/lib/DBI.pm line 545 via c:\inetpub\ line 51
-> STORE for DBD::mysql::db (DBI::db=HASH(0x281e5f0)~INNER 'AutoCommit' 1) thr#155424c
<- STORE= 1 at C:/Perl/site/lib/DBI.pm line 545 via c:\inetpub\ line 51
<- connect= DBI::db=HASH(0x281e500)
-> prepare for DBD::mysql::db (DBI::db=HASH(0x281e500)~0x281e5f0 'SELECT * FROM members WHERE mem_id = ?') thr#155424c
New DBI::st (for DBD::mysql::st, parent=DBI::db=HASH(0x281e5f0), id=)
dbih_setup_handle(DBI::st=HASH(0x281e644)=>DBI::st=HASH(0x281e464), DBD::mysql::st, 281e650, Null!)
dbih_make_com(DBI::db=HASH(0x281e5f0), DBD::mysql::st, 208) thr#155424c
dbih_setup_attrib(DBI::st=HASH(0x281e464), Err, DBI::db=HASH(0x281e5f0)) SCALAR(0x155cbc8) (already defined)
dbih_setup_attrib(DBI::st=HASH(0x281e464), State, DBI::db=HASH(0x281e5f0)) SCALAR(0x15641f4) (already defined)
dbih_setup_attrib(DBI::st=HASH(0x281e464), Errstr, DBI::db=HASH(0x281e5f0)) SCALAR(0x155cbe0) (already defined)
dbih_setup_attrib(DBI::st=HASH(0x281e464), Debug, DBI::db=HASH(0x281e5f0)) 0 (already defined)
dbih_setup_attrib(DBI::st=HASH(0x281e464), FetchHashKeyName, DBI::db=HASH(0x281e5f0)) 'NAME' (already defined)
dbih_setup_attrib(DBI::st=HASH(0x281e464), HandleError, DBI::db=HASH(0x281e5f0)) undef (not defined)
Setting mysql_use_result to 0
<- prepare= DBI::st=HASH(0x281e644) at c:\inetpub\ line 56
-> execute for DBD::mysql::st (DBI::st=HASH(0x281e644)~0x281e464 'K1016') thr#155424c
-> dbd_st_execute for 0281e4a0
Binding parameters: SELECT * FROM members WHERE mem_id = 'K1016'
<- dbd_st_execute 1 rows
<- execute= 1 at c:\inetpub\ line 59
-> fetchrow_array for DBD::mysql::st (DBI::st=HASH(0x281e644)~0x281e464) thr#155424c
-> dbd_st_fetch for 0281e4a0, chopblanks 0
dbih_setup_fbav for 5 fields => 0x15dc738
<- dbd_st_fetch, 5 cols
<- fetchrow_array= ( 'K1016' 'R1014' 'Karyn' 'Teadt' 'karen@maumee.com' ) [5 items] row1 at c:\inetpub\ line 62

Thank so much for any help, and
God Bless,
Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top