26

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....

27

Re: I need help

bump please

28 (edited by Jacq 2004-12-31 16:57)

Re: I need help

Too bad I didn't get here earlier.

Try EasyPHP: www.easyphp.org . It's basically n*next + finish installer for all the apps you need (Apache, PHP, MySQL) in Windows environment. Be sure to pick the right language in the installer as I picked French. The language is easy to change later though.

The website you create should be somewhere near C:\Program Files\EasyPHP1-7\home depending on your installation options and you can access it with your browser at http://localhost. The rest of the options are explained in the easyphp site and the accompanying files.