Welcome aboard! We are happy you are here and wish you good net-raft!
// this put into OpenDB.inc
<?php
function OpenDB ($Host="localhost", $Name="xxx", $Password="xxx", $DB="xxx" )
{
$ret=false;
$connect=MySQL_Connect($Host,$Name,$Password);
if(!$connect) echo "The connection is refused!";
else {
$ret=MySQL_SelectDB($DB);
if(!$ret) echo "The database is refused!";
}
return $ret;
}
?>
// this put into select.php
<?php
require_once('OpenDB.inc');
do {
if (!OpenDB()) break;
$sql="SELECT * FROM customers";
$result=mysql_query("$sql");
while ($record=mysql_Fetch_array($result))
{
// do something
}
MySQL_Close();
} while(false);
?>
The most helpful PHP solutions
detect browser phpPHP Click to see more ... 4.6K 408