RE: [PHP-DB] MySQL connect
| From: | Gurhan Ozen | Date: | Mon, 04 Feb 2002 18:29:39 +0000 |
| Subject: | RE: [PHP-DB] MySQL connect | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-16503@lists.php.net to get a copy of this message | ||
mysql_connect() function only takes 3 arguments (servername, username, pass)
.
Select your database by using mysql_select_db() function...
Try to rewrite the code as:
mysql_connect($db["host"],$db["user"],$db["password"]);
mysql_select_db($db["database"]);
Refer to:
http://www.php.net/manual/en/ref.mysql.php
Gurhan
-----Original Message-----
From: J Leonard [mailto:gcarlyle2@attbi.com]
Sent: Monday, February 04, 2002 12:54 PM
To: php-db@lists.php.net
Subject: [PHP-DB] MySQL connect
Hi all,
Ok I am learning this on my own but I could use some help.
I have started these two pages test.php and config.php here is the code:
test.php
<?
// include the database configuration
include "config.php";
// connect to database
mysql_connect($db["host"],$db["user"],$db["password"],$db["database"])
or
die ("sorry not successful");
// if no connect then exit
exit;
// if connect successful
echo ("you have connected");
?>
config.php
<?
// database config
$db["host"] = "localhost";
$db["user"] = "me";
$db["password"] = "mypassword";
$db["database"] = "mydb";
?>
All I'm trying to do is successfully connect to the database but it returns
"sorry not successful". What have I done wrong?
I have gone straight from the php pocket reference manual and it doesn't
work. Would someone please explain what has happened?
Thanks
J Leonard
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php