when I change the $dbh->fetchrow_array(); with WHILE loop :
While(our @rec = $dbh->fetchrow_array()){
our $name = $rec[1];
our $adminname = $rec[2];
our $myphone1 = $rec[3];
our $myphone2 = $rec[4];
our $myaddress = $rec[5];
our $mypercent = $rec[6];
}
and convert program to .exe , WHILE LOOP convert to Infinite loops .
--------------------------------------------------------------------------------------------------------------------------------------------
#!C:/strawberry/perl/bin/perl.exe
use Tk;
use DBI;
$mw = MainWindow->new(-background=>"gray");
$mw->title("$header");
$mw->maxsize(800,315);
$mw->minsize(800,315);
$cn = DBI->connect("DBI:mysql:telephontaxi","root","root",
{mysql_enable_utf8 => 1});
$dbh = $cn->prepare("select * from telephonetaxiinformation");
$dbh->execute();
our @rec = $dbh->fetchrow_array();
our $name = $rec[1];
our $adminname = $rec[2];
our $myphone1 = $rec[3];
our $myphone2 = $rec[4];
our $myaddress = $rec[5];
our $mypercent = $rec[6];
$dbh->finish;
$cn->disconnect;
$mw->Label(-text=>"$header",-font => "Titr 23",-anchor=>'center',-
width=>34,-background=>"gray")->place(-x => 0,-y=>0);
$fram = $mw->Frame(-relief => 'groove',-borderwidth => 0,-width=>780,-
height=>240)->place(-x => 10,-y=>64);
$fram->Entry(-font => "Tahoma 13 normal",-justify =>'right',-relief
=>'groove',-textvariable => \$name)->place(-x =>410,-y=>15);
$fram->Entry(-font => "Tahoma 13 normal",-justify =>'right',-relief
=>'groove',-textvariable => \$adminname)->place(-x =>410,-y=>55);
$fram->Entry(-font => "Tahoma 13 normal",-justify =>'right',-relief
=>'groove',-width=>4,-textvariable => \$mypercent)->place(-x =>170,-
y=>30);
$fram->Entry(-font => "Tahoma 13 normal",-justify =>'right',-relief
=>'groove',-textvariable => \$myphone1)->place(-x =>410,-y=>95);
$fram->Entry(-font => "Tahoma 13 normal",-justify =>'right',-relief
=>'groove',-textvariable => \$myphone2)->place(-x =>50,-y=>95);
$fram->Entry(-font => "Tahoma 13 normal",-width=>60,-justify
=>'right',-relief =>'groove',-textvariable => \$myaddress)->place(-x
=>50,-y=>145);
$fram->Button(-text=>"Save",-font => "Tahoma 13 normal",-command =>
[ \&saveinformation ])->place(-x =>370,-y=>190);
$fram->Button(-text=>"Exit",-font => "Tahoma 13 normal",-command =>
[$mw => 'destroy'])->place(-x =>320,-y=>190);
MainLoop;
sub saveinformation{
$cn = DBI->connect("DBI:mysql:telephontaxi","root","root",
{mysql_enable_utf8 => 1});
$dbh = $cn->prepare("update telephonetaxiinformation set
azansname='$name',azansadmin='$adminname',phone1='$myphone1',
phone2='$myphone2',azansaddress='$myaddress',azanspercent='$mypercent'
where azansid='1'");
$dbh->execute();
$cn->disconnect;
$dbh->finish;
$cn1 = DBI->connect("DBI:mysql:telephontaxi","root","root",
{mysql_enable_utf8 => 1});
$dbh1 = $cn1->prepare("select azansid from
telephonetaxiinformation where azansname='$name'");
$dbh1->execute();
my @rec = $dbh1->fetchrow_array();
print $rec[0];
if($rec[0] ne ""){
$message = "save correctly...";
$fram->Label(-text=>"$message",-font => "homa 15")->place(-
x =>600,-y=>190);
$mw->messageBox (
-default => 'Ok',
-title => "$message",
-message => "$message",
-type => 'Ok',
);
}
$dbh1->finish;
$cn1->disconnect;
}
On Mar 16, 11:58 pm, mohsen alizadeh <mohsenalizad...@gmail.com>
wrote:
I have tested packaging of DBD::mysql with Cava and Strawberry Perl, and
everything seems to work OK.
Changing your script as you suggested, putting the
$dbh->fetchrow_array(); with WHILE loop
would break your code anyway. You have package variables lexically
scoped within a while { loop }. I may have misunderstood, as you might
not have described your change in full.
Could you post some code that works if you do
perl myscriptname.pl
but does not work when myscriptname.pl is packaged with Cava?
Regards
Mark