View Single Post
  #13 (permalink)  
Old 11-02-2008, 05:18 PM
jwade_m's Avatar
jwade_m jwade_m is offline
Graphic/Web Designer
 
Join Date: Aug 2007
Location: Indiana, United States
Posts: 196
Default

Ok. Slightly different question now. Look below at the two sets of code. These are from two different connection files. They are coded differently, but will both work?

first set

$server = "mysql.hostname.com"; // this is the server address and port
$username = "fakeuser"; // change this to your jimmy username
$password = "passnotreal"; // change this to your jimmy password
$dbname = "databasename";

//User u70353840 with password 'f78c8' added to d60324644.
$link = mysql_connect ($server, $username, $password,$dbname)
or die ("Could not connect");
if (!@mysql_select_db("databasename", $link)) { // leave the database name as anydb for now
echo "

There has been an error. This is the error message:

";
echo "

" . mysql_error() . "

";
echo "Please Contant Your Systems Administrator with the details";
}


?>



second set
function connect_db()
{
$DBhost = "mysql.hosthost.com";//change
$DBuser = "fakename";//change
$DBpass = "fakepassword";//change
$DBName = "nameofdatabase";//change
$conn = mysql_connect($DBhost , $DBuser, $DBpass,$DBName)
or die("There was a problem connecting to MySQL. Please try again later.");

if (!@mysql_select_db("nameofdatabase", $conn))//change
{
die ("There was a problem connecting to the database. Please try again later.");
}
return $conn;
}

?>
Reply With Quote