[Q] DBI connect with MySQL

2001-03-01 Thread wen

Hi,gurus,
I am a novice at MySQL. When I try to run a sample program in the book of
"MySQL  mSQL" I get a error message from my apache server as follows,
*
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to 
complete your request.

Please contact the server administrator, [EMAIL PROTECTED] and inform them of the 
time the error occurred, and anything you might have done that may have caused the 
error.

More information about this error may be available in the server error log.
*

The sample program is 

#!/usr/bin/perl -w

use strict;
use CGI qw(:standard);
use CGI::Carp;
use DBI;
CGI::use_named_parameters(1);

my ($db);
my $output = new CGI;

$db = param('test') or die("Could not find database!");
my $dbh = DBI-connect("DBI:mysql:$db:$server",root,passward );

if (not $dbh) {
print header, start_html('title'="Information on $host = $db",
'BGCOLOR'='white');

print END_OF_HTML;
H1$host/h1
H2$db/h2
For the following reasons the connection failed.BR
$DBI::errstr
/body/html
END_OF_HTML
exit(0);
} 

print header, start_html('title'="Information on $host = $db",
'BGCOLOR'='white');
print END_OF_HTML;
H1$host/h1
H2$db/h2
p
Tablesbr
UL
END_OF_HTML

my @tables = $dbh-func( '_ListTables' );
foreach (@tables) {
 print "LI$_\n";
}
print END_OF_HTML;
/ul
/body/html
END_OF_HTML
   exit(0);


Could someone tell me what is wrong? Thanks a lot.

Regards,

--Wen
[EMAIL PROTECTED]

 


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: [Q] DBI connect with MySQL

2001-03-01 Thread ryc

You will get errors like these if your script does not print out a header
before spitting out other information. It is usually best to print the
header in the very beginning of the script so you do not have to worry about
it. You dont have to wait until you are about to print out some html.

$output-header();

Also, if your script has parse errors or something similar you will get that
error.

Hope this helps.

ryan



 Hi,gurus,
 I am a novice at MySQL. When I try to run a sample program in the book of
 "MySQL  mSQL" I get a error message from my apache server as follows,
 *
 Internal Server Error
 The server encountered an internal error or misconfiguration and was
unable to complete your request.

 Please contact the server administrator, [EMAIL PROTECTED] and inform
them of the time the error occurred, and anything you might have done that
may have caused the error.

 More information about this error may be available in the server error
log.
 *

 The sample program is

 #!/usr/bin/perl -w

 use strict;
 use CGI qw(:standard);
 use CGI::Carp;
 use DBI;
 CGI::use_named_parameters(1);

 my ($db);
 my $output = new CGI;

 $db = param('test') or die("Could not find database!");
 my $dbh = DBI-connect("DBI:mysql:$db:$server",root,passward );

 if (not $dbh) {
 print header, start_html('title'="Information on $host = $db",
 'BGCOLOR'='white');

 print END_OF_HTML;
 H1$host/h1
 H2$db/h2
 For the following reasons the connection failed.BR
 $DBI::errstr
 /body/html
 END_OF_HTML
 exit(0);
 }

 print header, start_html('title'="Information on $host = $db",
 'BGCOLOR'='white');
 print END_OF_HTML;
 H1$host/h1
 H2$db/h2
 p
 Tablesbr
 UL
 END_OF_HTML

 my @tables = $dbh-func( '_ListTables' );
 foreach (@tables) {
  print "LI$_\n";
 }
 print END_OF_HTML;
 /ul
 /body/html
 END_OF_HTML
exit(0);
 

 Could someone tell me what is wrong? Thanks a lot.

 Regards,

 --Wen
 [EMAIL PROTECTED]




 -
 Before posting, please check:
http://www.mysql.com/manual.php   (the manual)
http://lists.mysql.com/   (the list archive)

 To request this thread, e-mail [EMAIL PROTECTED]
 To unsubscribe, e-mail [EMAIL PROTECTED]
 Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: [Q] DBI connect with MySQL

2001-03-01 Thread wen

iii You will get errors like these if your script does not print out a header
iii before spitting out other information. It is usually best to print the
iii header in the very beginning of the script so you do not have to worry about
iii it. You dont have to wait until you are about to print out some html.
iii 
iii $output-header();

I add "$output-header();" just behind "my $output = new CGI;", but the 
result does not change. Maybe still there are other factors as you said. 
Thanks so much for your information.

Regards,

--Wen
[EMAIL PROTECTED]
 

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: [Q] DBI connect with MySQL(SOLVED)

2001-03-01 Thread wen

Okay, I get it. The problem comes from the statement below,

wen $db = param('test') or die("Could not find database!");

After I revised it to "my $db = "test" or die("Could not find database!");"
I get expected result.
Thanks for your consideration.

Regards,

--Wen
[EMAIL PROTECTED]

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: [Q] DBI connect with MySQL

2001-03-01 Thread Gerald L. Clark

Your Apache must be configured to support perl cgi scripts.
Is it?

What is in the Apache error log?

[EMAIL PROTECTED] wrote:
 
 Hi,gurus,
 I am a novice at MySQL. When I try to run a sample program in the book of
 "MySQL  mSQL" I get a error message from my apache server as follows,
 *
 Internal Server Error
 The server encountered an internal error or misconfiguration and was unable to 
complete your request.
 
 Please contact the server administrator, [EMAIL PROTECTED] and inform them of 
the time the error occurred, and anything you might have done that may have caused 
the error.
 
 More information about this error may be available in the server error log.
 *
 
 The sample program is
 
 #!/usr/bin/perl -w
 
 use strict;
 use CGI qw(:standard);
 use CGI::Carp;
 use DBI;
 CGI::use_named_parameters(1);
 
 my ($db);
 my $output = new CGI;
 
 $db = param('test') or die("Could not find database!");
 my $dbh = DBI-connect("DBI:mysql:$db:$server",root,passward );
 
 if (not $dbh) {
 print header, start_html('title'="Information on $host = $db",
 'BGCOLOR'='white');
 
 print END_OF_HTML;
 H1$host/h1
 H2$db/h2
 For the following reasons the connection failed.BR
 $DBI::errstr
 /body/html
 END_OF_HTML
 exit(0);
 }
 
 print header, start_html('title'="Information on $host = $db",
 'BGCOLOR'='white');
 print END_OF_HTML;
 H1$host/h1
 H2$db/h2
 p
 Tablesbr
 UL
 END_OF_HTML
 
 my @tables = $dbh-func( '_ListTables' );
 foreach (@tables) {
  print "LI$_\n";
 }
 print END_OF_HTML;
 /ul
 /body/html
 END_OF_HTML
exit(0);
 
 
 Could someone tell me what is wrong? Thanks a lot.
 
 Regards,
 
 --Wen
 [EMAIL PROTECTED]
 
 -
 Before posting, please check:
http://www.mysql.com/manual.php   (the manual)
http://lists.mysql.com/   (the list archive)
 
 To request this thread, e-mail [EMAIL PROTECTED]
 To unsubscribe, e-mail 
[EMAIL PROTECTED]
 Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php