|
Posted by Ney Andrι de Mello Zunino on 12/16/19 11:57
Hello.
Could anyone explain to me why the following code fails?
// =====Begin sample code=====
global $blog;
define("dbHost", "localhost");
define("dbUser", "ney");
define("dbPassword", "xxx");
define("dbDatabase", "blog");
function dbConnect()
{
// Stores the database resource link in the global array
$blog["db"] = mysql_connect(constant("dbHost"),
constant("dbUser"),
constant("dbPassword"))
or die("DB connection error: " . mysql_error());
mysql_select_db('blog')
or die("Error selecting blog database: " . mysql_error());
}
function dbDisconnect()
{
// Closes the connection represented by the resource link stored
// in the global array
mysql_close($blog["db"]);
}
dbConnect();
..
..
..
dbDisconnect();
// =====End sample code=====
Upon runtime, PHP produces the following warning:
Warning: mysql_close(): supplied argument is not a valid MySQL-Link
resource in /home/ney/Blog/db.php on line 22
I would appreciate if anyone could point out my mistake and kindly
explain the situation.
Thank you.
--
Ney AndrΓ© de Mello Zunino
Navigation:
[Reply to this message]
|