Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with MySQL on Win2k Adv Server......

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
Hi,
I've recently installed MySQL on my friends server that's running Win2k Adv. Server.

He has IIS (4.0 I believe, not positive though) running, and I'm trying to write a script to access a table in a DB, and just select all...

MySQL runs fine in the command prompt, but my script dies the second I try to connect the DB...

Assume that all I've done is installed MySQL and tested it from the command prompt.

Could someone please tell me how to connect to it from a script, select all, and then print it?

I'm using the following script:

----------------------------------------------
#!/usr/bin/perl

use DBI;
use CGI;

$foo = new CGI;

print $foo->header;

$dbuser = "test_user";
$dbpassword = "none";
$db_stuff = "DBI:mysql:Test_Database:";

my $dbh;
my $sth;

print &quot;<HTML>\n&quot;;
print &quot;<HEAD>\n<TITLE></TITLE>\n</HEAD>\n&quot;;

print &quot;<BODY BGCOLOR=WHITE TEXT=BLACK>\n&quot;;

print &quot;<BR>\n&quot;;
print &quot;<CENTER>\n&quot;;
print &quot;<FONT SIZE=+3><B>TESTING MYSQL</B></FONT><BR><BR>\n&quot;;
print &quot;</CENTER>\n&quot;;

print &quot;<TABLE WIDTH=500 BORDER=0 ALIGN=CENTER CELLPADDING=1 CELLSPACING=1>\n&quot;;
print &quot;Got this far 0&quot;; #using these just to find prob.
$dbd = DBI->connect($db_stuff, $dbuser, $dbpassword);
print &quot;Got this far 1&quot;;
$statement = &quot;SELECT field01, field02 FROM test_table&quot;;
print &quot;Got this far 2&quot;;
$sth = $dbh->prepare($statement) or die &quot;Can't prepare $statement: $dbh->errstr\n&quot;;
print &quot;Got this far 3&quot;;
$sth->execute or die &quot;Can't execute the query: $sth->errstr&quot;;
print &quot;Got this far 4&quot;;
my @row;

while (@row = $sth->fetchrow_array) {
print &quot;Got here&quot;;
$user_id = $row[0];
$member_name = $row[1];
$ph_points = $row[2];
print &quot;<TR>\n&quot;;
print &quot;<TD ALIGN=LEFT>&quot; . $user_id . &quot;<BR>\n&quot;;
print $member_name . &quot;<BR>\n&quot;;
print $ph_points . &quot;<BR>\n&quot;;
print &quot;<HR WIDTH=75%>\n&quot;;
}
$sth->finish;

print &quot;</TABLE>\n&quot;;

print &quot;</BODY>\n&quot;;
print &quot;</HTML>\n&quot;;
-----------------------------------------------------

The script dies the second it hits:
&quot;$dbd = DBI->connect($dbi_stuff, $dbuser, $dbpassword);&quot;

Could someone PLEASE help me?
I'm getting desperate.. heh


Thanx in advance for any help you may be able to provide,
Mayhem


 
i'm not so sure this is the problem but:

$dbd = DBI->connect($db_stuff, $dbuser, $dbpassword);
print &quot;Got this far 1&quot;;
$statement = &quot;SELECT field01, field02 FROM test_table&quot;;
print &quot;Got this far 2&quot;;
$sth = $dbh->prepa.....

you declare $dbd but then use $dbh. hope this helps..:) (-:
 
First of all what is the error your getting??!!??
Is it a 500?
You can run the PERL script with the -w in the shebang header(#!/usr/local/perl -w ...I know its windows but these directives should still work!)from the command line
(perl scriptname.pl of I think perl -w scriptname.pl)
this will check the syntax. If no errors are generated then you should see your html code. Often times programmers use the CGI extension in windows too.... (the isapi module is not mapped to handle that extension youshould use .pl if you use Active perl (
If you are using MySQL why not use the SQL
SELECT * from test_table


-NixerX
Let me know how it turns out!
kernel_killer@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top