liudaheng:
"old way" or "new style"
It doesn't matter which way you do it, but either way you need to have the same basic information.
Using the "old way" you entered the hostname, user, and password. Doing it the "new style" you still need to have that same information in your function and then you just call the function.
Something like this should work to connect to MySQL and a single database:
// Connect to a single db
function dbconn() {
$dbUser = “myuser”;
$dbPass = “mypassword”;
$dbName = “mydatabase”;
$dbHost = “myhost”;
if (!($link=mysql_connect($dbHost, $dbUser, $dbPass))) {
error_log(mysql_error(), 3, “/tmp/phplog.err”);
}
if (!mysql_select_db($dbName, $link)) {
error_log(mysql_error(), 3, “/tmp/phplog.err”);
}
}
If there is an error either in the connection to MySQL or to the database, the error will be written to a temporary file phplog.err.
I have not seen $result used when creating a connection to MySQL or to a database.
The use of $result that I am familiar with is when you are creating a query like this:
$query = “SELECT Surname FROM personal_info WHERE ID<10”;
$result = mysql_query($query);
Try writing your connection function something like the above example and get rid of the $result stuff.
I think this will work for you.
Good Luck!
If your problem has been solved, please mark thread Resolved.