RE: mysql connect error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi

Check the database name is exactly the same case as you are using - not
Soverign rather soverign for example.

After that try the raw php functions for connecting to the database


<?php
//require_once 'DB.php';
$user = 'jbyrne';
$pass = '';
$host = 'localhost';
$db_name = 'sovereign';

if($dsn = mysql_connect($host,$user,$pass)) echo 'connected ok' ;
else echo 'Failed to connect to database'.mysql_error( $dsn) ;

if(mysql_select_db($db_name, $dsn )) echo 'selected db ok';
else echo 'Failed to select to database'.mysql_error( $dsn) ;


?>

This will give the Mysql error messages which should give you more
information

HTH, if not comeback to me

Peter








-----Original Message-----
From: John Byrne [mailto:jjbyrne@alphalink.com.au]
Sent: 12 August 2003 08:06
To: php-db@lists.php.net
Subject:  mysql connect error


Hi,

I've just started playing with Linux/MySQL/PHP - I come from a
Windows/ASP/PowerBuilder background.

I have created a database in MySQL and now are trying to connect to it via
PHP. I keep getting the same error, no matter what I specify in DSN. I
always get:

DB Error: no such database

The following is the PHP code I am using:

<?php
require_once 'DB.php';
$user = 'jbyrne';
$pass = '';
$host = 'localhost';
$db_name = 'sovereign';
$dsn = "mysql://$user:$pass@$host/$db_name";
$db = DB::connect($dsn);
if (DB::isError($db)) {
   die ($db->getMessage());
}
....
$db->disconnect();
?>

This is straight out of the PHP documentation.

Any ideas why I get the same error all the time.

I am using RedHat 8.0, PHP 4.2.2, MySQL 3.2.53, Apache 2.0

thanks





--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux