Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

wwwxxx,nvif, why atm producer might be held liable for economic injury, wwwxxxy=ServiceLogin, w2ksp4.exe, WwwxxXdbf, procmail "FROM_MAILER" patch, Use of assignment to $[ is deprecated at /usr/local/sbin/apxs line 86. , wwwxxx vim, mysql closing table and opening table, 800c5000

Links

XODOX
Impressum

#1: I have a problem but cant find it

Posted on 2008-03-24 20:21:22 by Armando Gomez

Hello all!


a friend send me a script that can make a query from a MySQL into a
HTML Page
it has an error something like this but I dont know what is wrong
the error code :

Can't find string terminator "EOUsage" anywhere before EOF at
returnatable.pl line 7.


this is the code I am using perl for windows :

#!/usr/bin/perl
use DBI;
#Get arguments from command line
($db,$table,$out_file,$user,$pass)=@ARGV;
#Check for invalid info
unless($db && $table) {
print <<EOUsage;
Usage: $0 <database> <table> <out file> <user> <pass>
\tUnless you specify out file, STDOUT will be used.
\t(Sending an out file of '-' will generate the same result)
\tUser and Pass are optional.

EOUsage
exit();
}
#No out file if '-'
undef $out_file if($out_file eq '-');
#Connect to the DBI using our db, user, and pass
my $dbr=DBI->connect("dbi:mysql:$db",$user,$pass,{
PrintError=>0
}) or die "Can't connect to database; $DBI::errstr\n";
#Get all the rows from our table
my $sth=$dbr->prepare("SELECT * FROM $table")
or die "Can't prepare SQL statement: $DBI::errstr\n";
#Execute our command to get the rows
$sth->execute or die "Can't execute: $DBI::errstr\n";
#Open out_file
if($out_file) {
#Don't open file until now to avoid overwritting
# in case of errors
open OUT,">$out_file" or die "Cannot open $out_file for
writting: $!\n";
}
#Header html data
$head=<<EOHead;
<html>
<head>
<title>Database Summary</title>
</head>
<body>
<h1>Data in $db:$table</h1>
<table border=1>
EOHead
out($head);
#Print a table row for each database row
my @row;
while(@row=$sth->fetchrow_array()) {
out("<tr><td>" . join("</td><td>",@row) . "</td></tr>\n");
}
#HTML tail info
$tail=<<EOTail;
</table>
</body>
</html>
EOTail
#Close out_file
if($out_file) {
close OUT;
}
#Disconnect from the database
$dbr->disconnect;
#Use this sub to make it easier when using file || STDOU
sub out {
my $data=shift;
if($out_file) {
print OUT $data;
} else {
print $data;
}
}


I hope someone could help me thanks!


--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org

Report this message

#2: Re: I have a problem but cant find it

Posted on 2008-03-24 20:33:12 by Jake Peavy

------=_Part_9606_19800219.1206387192155
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

On 3/24/08, Armando Gomez <armando.gomez@aaahmt.com> wrote:
>
> Hello all!
>
>
> a friend send me a script that can make a query from a MySQL into a
> HTML Page
> it has an error something like this but I dont know what is wrong
> the error code :
>
> Can't find string terminator "EOUsage" anywhere before EOF at
> returnatable.pl line 7.
>
>
> this is the code I am using perl for windows :
>
> #!/usr/bin/perl
> use DBI;
> #Get arguments from command line
> ($db,$table,$out_file,$user,$pass)=@ARGV;
> #Check for invalid info
> unless($db && $table) {
> print <<EOUsage;
> Usage: $0 <database> <table> <out file> <user> <pass>
> \tUnless you specify out file, STDOUT will be used.
> \t(Sending an out file of '-' will generate the same result)
> \tUser and Pass are optional.
>
> EOUsage
> exit();
> }


<snip>

I hope someone could help me thanks!
>

The terminator for a here-doc cannot be indented. Move EOUsage to the left.

--
-jp

You know something that would really make me applaud? A guy gets stuck in
quicksand, then sinks, then suddenly comes shooting out, riding on water
skis! How do they do that?!

deepthoughtsbyjackhandy.com

------=_Part_9606_19800219.1206387192155--

Report this message

#3: Re: I have a problem but cant find it

Posted on 2008-03-24 23:27:01 by Baron Schwartz

Hi,

On Mon, Mar 24, 2008 at 3:33 PM, Jake Peavy <djstunks@gmail.com> wrote:
> On 3/24/08, Armando Gomez <armando.gomez@aaahmt.com> wrote:
> >
> > Hello all!
> >
> >
> > a friend send me a script that can make a query from a MySQL into a
> > HTML Page
> > it has an error something like this but I dont know what is wrong
> > the error code :
> >
> > Can't find string terminator "EOUsage" anywhere before EOF at
> > returnatable.pl line 7.
> >
> >
> > this is the code I am using perl for windows :
> >
> > #!/usr/bin/perl
> > use DBI;
> > #Get arguments from command line
> > ($db,$table,$out_file,$user,$pass)=@ARGV;
> > #Check for invalid info
> > unless($db && $table) {
> > print <<EOUsage;
> > Usage: $0 <database> <table> <out file> <user> <pass>
> > \tUnless you specify out file, STDOUT will be used.
> > \t(Sending an out file of '-' will generate the same result)
> > \tUser and Pass are optional.
> >
> > EOUsage
> > exit();
> > }
>
>
> <snip>
>
>
> I hope someone could help me thanks!
> >
>
> The terminator for a here-doc cannot be indented. Move EOUsage to the left.

Or change the beginning to this:

print <<" EOUsage";

(Insert the correct number of spaces/tabs so it matches the line that
terminates the here-doc).

--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org

Report this message