[PHP] connecting to a database

Need help with C, C++, perl, python, etc?

[PHP] connecting to a database

Postby PL99 » 2004-04-23 17:38

I think I have to edit some config file someware because I'm getting a strange error. ( Or at least I think it's a little odd.)

I know the the database "report" exists, I made it with phpmyadmin.
I have the following code :

Code: Select all
mysql_connect($db_host,$user, $passwd) or die ("Failed to connect to the MySQL server!");
mysql_select_db ("report") or die ("Failed to connect to the database!");


and I get the following error:
Failed to connect to the database!

Somebody an idea what's the problem?

THX
PL99
 
Posts: 24
Joined: 2004-03-05 21:43
Location: Austria

Postby MarkvD » 2004-04-23 19:08

Try
Code: Select all
mysql_connect("$db_host",$user, "$passwd") or die ("Failed to connect to the MySQL server!");

and:
Code: Select all
mysql_select_db ("report") or die (mysql_error()); // to get get information about the error
User avatar
MarkvD
Site admin
 
Posts: 94
Joined: 2004-02-15 21:36
Location: Rhoon, Holland

Postby PL99 » 2004-04-24 06:28

Thanks,

mysql_select_db(); gave an error.
The user could not log in.
$db_user, $user and $passwd where not known, The include file where they were defined wasn't ok.

Everything is ok now, Thanks.
PL99
 
Posts: 24
Joined: 2004-03-05 21:43
Location: Austria


Return to Programming

Who is online

Users browsing this forum: No registered users and 5 guests

fashionable