I'm using the code from the SitePoint.com forum article "Managing Users with PHP Sessions and MySQL". For some reason I am unable to connect to my database. After I type in the username and password and click login, the page shows the line "The site database is unavailable.". But I know it IS available, b/c I'm able to login using an old script I have.
Can anyone tell me how my db details should fit into this code so I can properly connect?
Let's say my db details are:
server: sql3.oururl.com
username: admin
password: pw
database name: ffdb1
Can anyone tell me how my db details should fit into this code so I can properly connect?
Let's say my db details are:
server: sql3.oururl.com
username: admin
password: pw
database name: ffdb1
Code:
<?php // db.php
$dbhost = "localhost";
$dbuser = "user";
$dbpass = "password";
function dbConnect($db="") {
global $dbhost, $dbuser, $dbpass;
$dbcnx = @mysql_connect($dbhost, $dbuser, $dbpass)
or die("The site database appears to be down.");
if ($db!="" and !@mysql_select_db($db))
die("The site database is unavailable.");
return $dbcnx;
}
?>