For Programmers: Free Programming Magazines  


Home > Archive > PERL CGI Beginners > May 2004 > questions about bind_param and mysql trace data included









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author questions about bind_param and mysql trace data included
smrtalec@algxmail.com

2004-05-22, 11:32 am



below I have a snippet from a trace file read out for a section of code below. The problem seems to be with '$sth->bind_param (2,$rh_row->{prop_str_addr});' The first Bind works fine however the next one in the line listed produces a null entry per the tr
ace file. I have verified that the data is correct in '$rh_row->{prop_str_addr}' and that it is quoted but for some reason myql isn't recieving the data any help would be appreciated.

<- dbd_st_execute 0 rows
<- execute= '0E0' at db_load_1-2.pl line 128
-> bind_param for DBD::mysql::st (DBI::st=HASH(0x8104f14)~0x8104e3c 1 ''310-673-5515'')
<- bind_param= 1 at db_load_1-2.pl line 122
-> execute for DBD::mysql::st (DBI::st=HASH(0x8104f14)~0x8104e3c)
-> dbd_st_execute for 08104e48
Binding parameters: UPDATE own_info
SET own_phone_home = ''310-673-5515''
WHERE own_str_addr = NULL



###############################CODE SNIPPETTE########################
$dbh = connect_try("******","******");
foreach $k (keys (%{$ar_info->[1]})){ # retrieves a generic set of fields and uses them to assign values for each row.
if ($table eq "prop_info"){ # checks which table is being used and assigns the correct SQL statement
$sth = $dbh->prepare ("UPDATE prop_info
SET $k = ?
WHERE prop_str_addr = ?") or
err_trap("failed to prepare statement\n");
}elsif ($table eq "own_info"){
$sth = $dbh->prepare ("UPDATE own_info
SET $k = ?
WHERE own_str_addr = ?") or
err_trap("failed to prepare statement\n");


}
$sth->trace(2, "./trace_data.txt");
foreach $rh_row (@$ar_info) { # iterates through the list of rows and assigns the correct value to the field
print "::$k=>$rh_row->{$k}"; # this is an internal check to verify what values are being inserted
$sth->bind_param (1,$rh_row->{$k});
if ($table eq "prop_str_addr") {
$sth->bind_param (2,$rh_row->{prop_str_addr});
}elsif ($table eq "own_str_addr") {
$sth->bind_param (2,$rh_row->{own_str_addr});
}
$sth->execute() or
err_trap("failed to execute statement\n");

}
print "\n===========================\n";

}
$sth->finish();
$dbh->disconnect or
err_trap("failed to disconnect statement\n");

Brad Lhotsky

2004-05-22, 11:32 am

Try this:

On Tue, May 11, 2004 at 12:51:28PM -0700, smrtalec@algxmail.com wrote:
>
>
> below I have a snippet from a trace file read out for a section of code below. The problem seems to be with '$sth->bind_param (2,$rh_row->{prop_str_addr});' The first Bind works fine however the next one in the line listed produces a null entry per the

trace file. I have verified that the data is correct in '$rh_row->{prop_str_addr}' and that it is quoted but for some reason myql isn't recieving the data any help would be appreciated.
>
> <- dbd_st_execute 0 rows
> <- execute= '0E0' at db_load_1-2.pl line 128
> -> bind_param for DBD::mysql::st (DBI::st=HASH(0x8104f14)~0x8104e3c 1 ''310-673-5515'')
> <- bind_param= 1 at db_load_1-2.pl line 122
> -> execute for DBD::mysql::st (DBI::st=HASH(0x8104f14)~0x8104e3c)
> -> dbd_st_execute for 08104e48
> Binding parameters: UPDATE own_info
> SET own_phone_home = ''310-673-5515''
> WHERE own_str_addr = NULL
>
>
>
> ###############################CODE SNIPPETTE########################
> $dbh = connect_try("******","******");
> foreach $k (keys (%{$ar_info->[1]})){ # retrieves a generic set of fields and uses them to assign values for each row.
> if ($table eq "prop_info"){ # checks which table is being used and assigns the correct SQL statement
> $sth = $dbh->prepare ("UPDATE prop_info
> SET $k = ?
> WHERE prop_str_addr = ?") or
> err_trap("failed to prepare statement\n");
> }elsif ($table eq "own_info"){
> $sth = $dbh->prepare ("UPDATE own_info
> SET $k = ?
> WHERE own_str_addr = ?") or
> err_trap("failed to prepare statement\n");
>
>
> }
> $sth->trace(2, "./trace_data.txt");
> foreach $rh_row (@$ar_info) { # iterates through the list of rows and assigns the correct value to the field
> print "::$k=>$rh_row->{$k}"; # this is an internal check to verify what values are being inserted
> $sth->bind_param (1,$rh_row->{$k});


if($table eq 'prop_info') {

> if ($table eq "prop_str_addr") {
> $sth->bind_param (2,$rh_row->{prop_str_addr});
> }elsif ($table eq "own_str_addr") {
> $sth->bind_param (2,$rh_row->{own_str_addr});
> }
> $sth->execute() or
> err_trap("failed to execute statement\n");
>
> }
> print "\n===========================\n";
>
> }
> $sth->finish();
> $dbh->disconnect or
> err_trap("failed to disconnect statement\n");
>
>
> --
> To unsubscribe, e-mail: beginners-cgi-unsubscribe@perl.org
> For additional commands, e-mail: beginners-cgi-help@perl.org
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>


--
Brad Lhotsky <brad@divisionbyzero.net>
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com