LithMaster
23 Aug 2005, 04:29 PM
Hi, does anyone know what is wrong with this PHP Function? i can't use $Result after this, it says it's an undefined variable
function DBConnect($DB,$SQL,$DBHost,$DBUsername,$DBPassword)
{
$DBConnectNum=1;
$Conn= mysqli_connect($DBHost,$DBUsername,$DBPassword) or die(mysqli_error($Conn)."<br />Database is not available at this moment, please try again later,<br /> SQL Connect Num=$DBConnectNum ");
$DBS= mysqli_select_db($Conn,$DB) or die(mysqli_error($DBS)."<br />The required database is not available, please try again later,<br /> SQL Connect Num=$DBConnectNum");
$Query= mysqli_query($Conn,$SQL) or die(mysqli_error($Conn)."<br /> We could not query the database, please try again later,<br /> SQL Connect Num=$DBConnectNum");
$Result= mysqli_fetch_array($Query);
mysqli_close($Conn);
$DBConnectNum++ ;
return $Result;
}
function DBConnect($DB,$SQL,$DBHost,$DBUsername,$DBPassword)
{
$DBConnectNum=1;
$Conn= mysqli_connect($DBHost,$DBUsername,$DBPassword) or die(mysqli_error($Conn)."<br />Database is not available at this moment, please try again later,<br /> SQL Connect Num=$DBConnectNum ");
$DBS= mysqli_select_db($Conn,$DB) or die(mysqli_error($DBS)."<br />The required database is not available, please try again later,<br /> SQL Connect Num=$DBConnectNum");
$Query= mysqli_query($Conn,$SQL) or die(mysqli_error($Conn)."<br /> We could not query the database, please try again later,<br /> SQL Connect Num=$DBConnectNum");
$Result= mysqli_fetch_array($Query);
mysqli_close($Conn);
$DBConnectNum++ ;
return $Result;
}