Re: I need help
how do i do this?????
Testing MySQL
Testing MySQL is not exactly easy. However, here are the common connection strings for PHP and CGI. I recommend downloading phpMyAdmin and using it to create and manage your databases, etc.
PHP Connection test
<?php
// hostname or ip of server (for local testing, localhost should work)
$dbServer='localhost';
// username and password to log onto db server (what you entered in Step 4)
$dbUser='root';
$dbPass='';
// name of database (what you created in step 4)
$dbName='test';
$link = mysql_connect("$dbServer", "$dbUser", "$dbPass") or die("Could not connect");
print "Connected successfully<br>";
mysql_select_db("$dbName") or die("Could not select database");
print "Database selected successfully<br>";
// close connection
mysql_close($link);
?>
CGI Connection test (Must have DBI module installed)
#!/usr/bin/perl
print "Content-type: text/html\n\n";
# DBI is perl module used to connect to the database
use DBI;
# hostname or ip of server (for local testing, localhost should work)
$config{'dbServer'} = "localhost";
# username and password to log onto db server (what you entered in Step 4)
$config{'dbUser'} = "root";
$config{'dbPass'} = "";
# name of database (what you created in step 4)
$config{'dbName'} = "test";
# MySQL driver (shouldn't need to change)
$config{'dataSource'} = "DBI:mysql:$config{'dbName'}:$config{'dbServer'}";
my $dbh = DBI->connect($config{'dataSource'},$config{'dbUser'},$config{'dbPass'}) or
die "Can't connect to $config{'dataSource'}<br>$DBI::errstr";
print "Connected successfully<br>";
$dbh->disconnect();
Some notes for CGI users
If you do not know how to install DBI here's how (you can go to www.cpan.org and do it by hand, but this is waaaay easier).
On your start menu there should be a ActiveState ActivePerl 5.8 > Perl Package Manager shortcut. Run it then type install dbi and it will download and install that module. When that finishes type install DBD-mysql and you are ready to go.
please help....