Can't connect to database

admin

Administrator
Staff member
<?

$dbhost = 'localhost';
$dbusername = 'username';
$database_name = 'dbname';


$connection = mysql_pconnect($dbhost , $dbusername)
or die ("Couldn't connect to server.");

$db = mysql_select_db( $database_name , $connection)
or die("Couldn't select database.");
?>

Can someone tell me if anything is wrong with this code because when I try to access the database it says "Couldn't select database." I'm using lycos to play around with MySQL so I know that not having a password isn't it because they dont give passwords for their databases. Anyone who could tell me where I'm messing up?you have to have a password. why would anybody not set a password? maybe you have your dbname wrong.Nah, I didn't have the dbname wrong..but I did figure out why it wouldn't work. MySQL wasn't enabled and I tried for about 15 minutes to enable it and I couldn't get it to activate, by that time I was pissed and just closed my lycos.co.uk account.wha tdo you mean not enabled? you connected to it but just couldn't get the db being that you had the name wrong.

but if you closed it then no worries.OH..lol..But it couldn't have been the wrong name, I checked and rechecked it but I'm gonna open up another account and try again. Maybe I can get it to work, wish me luck, I'll need it.;)look at it this way. did you get this error?

"Couldn't connect to server."

it doesn't seem so, so that means you connected. once connected you needed the dbname or it would error out. so even though you connected you either had the wrong name or there is no such dbname.
 
Top