Gossamer Forum
Home : General : Perl Programming :

could any one hlep me?

Quote Reply
could any one hlep me?
I have been frustrated for the problem as i could not find out what has been wrong.

The script is tested ok while after it failed after i uninstall a software, the perl script give me a error when i run it. any help would be greatly appreciated

Here is the error message:

------------------

Statement has no result columns to bind (perhaps you need to successfully call execute first) at H:\webtest\cgi-bin\eziaccess-demo\login.pl line 121.

-------------------------

the code is as following:

#############

$sql_syntax = qq(SELECT ID, recipID, NAME FROM $table_recipient WHERE ( Sender_ID ='$sender_ID') );line 118


&SQL_EXE($dbh,$sql_syntax);#line 119


my( $ID, $recipID, $NAME);#line 120


$sth->bind_columns( undef, \$ID, \$recipID, \$NAME);#line 121

&Template($template_head);#line 122

#######
Quote Reply
Re: [jack222] could any one hlep me? In reply to
From perldoc:

>>
Calls /bind_col for each column of the SELECT statement. The bind_columns method will die if the number of references does not match the number of fields.

For maximum portability between drivers, bind_columns should be called after execute.
<<

I believe you can change:

$sth->bind_columns( undef, \$ID, \$recipID, \$NAME);

to

$sth->bind_columns( undef, \($ID, $recipID, $NAME));

also.

Last edited by:

RedRum: Jan 17, 2002, 2:48 AM
Quote Reply
Re: [RedRum] could any one hlep me? In reply to
Amazing. Redrum. I got your so fast reply.

Unfortunately the alternation is not work for me. The script orginally is worked. while it fails only after unisntalled a software. weather i accidently del a file while cause this problem? as i backup a copy of workable scirpt . Right now even i restore the workable script , it still not work for me.

any other reason? while your suggestion is appreciated. As i am not good at the scirpt programming, I need time to see the document you point me.
Quote Reply
Re: [jack222] could any one hlep me? In reply to
If possible could you attach the whole script to a post?

Here is the perldoc I pasted from:

http://www.perldoc.com/perl5.6.1/lib/DBI.html
Quote Reply
Re: [RedRum] could any one hlep me? In reply to
Here is the code:

###########

#!/usr/bin/perl

######################################################################################
##
## Program : login.pl
#&Template($template_head);
#&Template($template_template_maininfos1);
#&Template($template_template_maininfos2);
#&Template($template_foot);
#####################################################################
#### start setup ####
$template_login_form = 'H:/webtest/cgi-bin/demo/template_login_form.html';
$template_head = 'H:/webtest/cgi-bin/demo/template_head.html';
$template_foot = 'H:/webtest/cgi-bin/demo/template_foot.html';
$template_template_maininfos1 = 'H:/webtest/cgi-bin/demo/template_maininfos1.html';
$template_template_maininfos2 = 'H:/webtest/cgi-bin/demo/template_maininfos2.html';


$template_show_data_for_members = 'H:/webtest/cgi-bin/demo/data_for_members.html';
$template_head = 'H:/webtest/cgi-bin/demo/template_head.html';
$template_enable_error = 'H:/webtest/cgi-bin/demo/template_enable_error.html';

#### end of setup ####
#####################################################################

#####################################################################
#### start program ####

use DBI;
require "H:/webtest/cgi-bin/demo/config.pl";
require "H:/webtest/cgi-bin/demo/module.pl";
require 'H:/webtest/cgi-bin/admin/smart.cfg';
require 'h:/webtest/cgi-bin/admin/cookie.lib';


# Get the date
&get_date;
&get_host;
#&random_cookie();
&Indata();


$username = $input{'username'};
$password = $input{'password'};


print "Pragma: no-cache\n";
print "Content-type:text/html\n\n";

if (!$username || !$password) { &Template($template_login_form); exit; }
else { &Login(); }




#### end of program ####
#### Start sub program. Don't touch anything below ####

sub Login {
my $yes_members = '';
my $xusername = '';
my $xpassword = '';

&SQL_CONNECT();

# Check username and password
$sql_syntax = qq(SELECT USERNAME,PASSWORD FROM $table_sender WHERE (ACTIVE = 'NO'));
&SQL_EXE($dbh,$sql_syntax);
while (my $ref = $sth->fetchrow_hashref) {
$xusername = $ref->{USERNAME};
$xpassword = $ref->{PASSWORD};
if (($xusername eq $username) && ($xpassword eq $password)) { $yes_members = 1; last; }
}

#update database infos########################################
if (!$yes_members) { # Cannot find username to enable
&Template($template_enable_error);
exit;
}
else { # Store registration data to datable for confirmation
$sql_syntax =qq(
UPDATE $table_members
SET ACTIVE = 'YES', EMAIL = 'emailaddress'
WHERE (USERNAME = '$username')
);

&SQL_EXE($dbh,$sql_syntax);

#####################################################
$sql_syntax = qq(SELECT ID, sender_ID, NAME, EMAIL FROM $table_sender WHERE ( USERNAME = '$username'));
&SQL_EXE($dbh,$sql_syntax);
my( $ID, $sender_ID, $NAME, $EMAIL);
$sth->bind_columns( undef, \$ID, \$sender_ID, \$NAME, \$EMAIL );

#############################
&Template($template_head);
&Template($template_template_maininfos1);
###&Template($template_template_maininfos2);
###&Template($template_foot);

##############################

while( $sth->fetch() )
{
# print "($ID) $NAME / $EMAIL / $sender_ID \n";

#print "<P>*$username $password the end of first login sender part------------------------------------------------------------------</P>\n\n";

}

#}####### has combine two in one


#############the start of recipient
$sql_syntax = qq(SELECT id, recipID, Name FROM $table_recipient WHERE ( Sender_ID ='$sender_ID') );
&SQL_EXE($dbh,$sql_syntax);
my( $id, $recipID, $Name);
#$sth->bind_columns ( undef, \ $id, \$recipID, \$Name );
$sth->bind_columns( undef, \($id, $recipID, $Name));


#&Template($template_head);




# See if they have a cart already, if not, make one
&check_file; ( TO CHECK COOKIE)
&list_items88; ### list all purchased item
&list_items2;



#######the end of recipient data extract
#############################################$address

####

print<<"[HTML]";
<!-- TABLE II COLUMN II START ------------------------------>

<form action="http://buypro.homeip.net/...ip.pl?command=recip1" method="post" >
<center>请选择收货人的姓名<br>--------------------------<br> <br>
<input type="hidden" name="senderID" value='$sender_ID'>
* <select name="recip">
<option value=" " selected>从我的地址簿中选择收货人</option>
[HTML]
###
while( $sth->fetch() )
{
print<<"[HTML]";
<option value="$recipID">$NAME</option>
[HTML]

###########
}
####


print<<"[HTML]";
<option value="newrecip" >**********>其它的收货人</option>
</select>


<input name type="submit" value=" next setp............. ">
</FORM>
<br>
<center>

[HTML]
#######the end of recipient data extract
&Template($template_template_maininfos2);
&Template($template_foot);
}

#######the end of recipient data extract

$sth->finish();
$dbh->disconnect();
#&Template($template_head);

}



exit;

###############
Quote Reply
Re: [jack222] could any one hlep me? In reply to
###########sub routines

sub Template {
my ($template) = @_;
my $HTML="";

open (TEMPLATE, "$template") || die print "CAN NOT OPEN TEMPLATE FILE : $template : $!";
while(<TEMPLATE>) { $HTML .= $_; }
close(TEMPLATE);

$HTML =~ s/\$(\w+)/${$1}/g;
print $HTML;
}





sub Indata {
if ($ENV{'REQUEST_METHOD'} eq "GET"){ $buffer=$ENV{'QUERY_STRING'};}
elsif ($ENV{'REQUEST_METHOD'} eq "POST"){read(STDIN,$buffer,$ENV{'CONTENT_LENGTH'});}
@pairs = split(/&/,$buffer);
foreach $pair (@pairs){
($name,$value) = split(/=/,$pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
$input{$name}=$value;}
}





sub Remove_what_you_want {
local ($str) = @_;
$str =~s{[\r\t]}{}gi;
$str =~s/</&lt;/g;
$str =~s/>/&gt;/g;
$str =~s/\n/<br>/g;
return $str;
}







sub SQL_CONNECT {

$dbh = DBI->connect("DBI:$sql_driver:$sql_database:$sql_server","$sql_user","$sql_password");
if (!$dbh) {

$DATA.= qq(-----------------------------------------------------------------------------------------------------------------------------------);
$DATA.= qq(<br><br><b>Error</b> : ) . DBI::errstr . qq(<br><br>);
$DATA.= qq(-----------------------------------------------------------------------------------------------------------------------------------);
$DATA.= qq(<br><br><input type='button' name='back' value='<-- Back' onclick='javascript:history.back()'> );

print $DATA;
exit;
}
return $dbh;
}





sub SQL_EXE {
local ($dbh,$sql_syntax) = @_;

$sth = $dbh->prepare($sql_syntax);
if (!$sth->execute) {
$DATA.= qq(-----------------------------------------------------------------------------------------------------------------------------------);
$DATA.= qq(<br><br><b>Error</b> : ) . $sth->errstr . qq(<br><br>);
$DATA.= qq(-----------------------------------------------------------------------------------------------------------------------------------);
$DATA.= qq(<br><br><input type='button' name='back' value='<-- Back' onclick='javascript:history.back()'> );

print $DATA;
exit;
}
}

#################below sub routine is for order cart processingsub
Quote Reply
Re: [RedRum] could any one hlep me? In reply to
Dear RedRum ,



I finally found that the mysql data has some problem. When i use sql dump,

i only get the relative table structure while has no actual data at all. while other table are function good.



i have see the data of that table and its field definition. and could not find any error, could you point me what is the possible reason ? I only could recall before the scripts fail, there is a unknow reason reboot, weather that reboot spoiled the table data?



Thanks

Austin