Hello.
Could anyone explain to me why the following code fails?
// =====Begin sample code=====
global $blog;
define("dbHost" , "localhost" );
define("dbUser" , "ney");
define("dbPassw ord", "xxx");
define("dbDatab ase", "blog");
function dbConnect()
{
// Stores the database resource link in the global array
$blog["db"] = mysql_connect(c onstant("dbHost "),
constant("dbUse r"),
constant("dbPas sword"))
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($bl og["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
Could anyone explain to me why the following code fails?
// =====Begin sample code=====
global $blog;
define("dbHost" , "localhost" );
define("dbUser" , "ney");
define("dbPassw ord", "xxx");
define("dbDatab ase", "blog");
function dbConnect()
{
// Stores the database resource link in the global array
$blog["db"] = mysql_connect(c onstant("dbHost "),
constant("dbUse r"),
constant("dbPas sword"))
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($bl og["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
Comment