Hi. I need help with a PDO connection. I am tyring to upgrade to PDO as my web host is doing a major upgrade. I have a working connection object at the top of the file. On line 72 I need to pass it into the function LpgMeX2(). I can’t pass it as an argument because the calling function only supplies 3 arguments. It doesn’t know about the database.
If I do function LogMeX2($conn, $name , $pwd1, $Sector) then I get an error
Warning: Missing argument 4 for LogMeX2()
CODE:
`` <?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
define ('HOSTNAME1', 'mysql09.iomart.com');
define ('USERNAME1', 'otoogc692');
define ('PASSWORD1', 'mauritius');
define ('DATABASE1', 'otoogc692');
$host = HOSTNAME1;
$user = USERNAME1;
$pass = PASSWORD1;
$MyDB = DATABASE1;
$conn = new PDO("mysql:host=$host; dbname=$MyDB; charset=UTF8", $user, $pass, [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => false,
]);
function Session_Init()
{
if (!isset($GET['counter']))
$GET['counter'] = "";
if (!isset($SESSION['current_page']))
$SESSION['current_page'] = '';
if (!isset($SESSION['Event_Log']))
$SESSION['Event_Log'] = '';
if (!isset($SESSION['K9']))
$SESSION['K9'] = '';
if (!isset($SESSION['Survalance']))
$SESSION['Survalance'] = '';
if (!isset($SESSION["K208"]))
$SESSION["K208"] = '';
if (!isset($SESSION["Error_1"]))
$SESSION["Error_1"] = '';
if (!isset($SESSION["Error_2"]))
$SESSION["Error_2"] = '';
if (!isset($SESSION["Error_3"]))
$SESSION["Error_3"] = '';
if (!isset($SESSION["Error_4"]))
$SESSION["Error_4"] = '';
if (!isset($SESSION["Error_5"]))
$SESSION["Error_5"] = '';
if (!isset($SESSION["Current"]))
$SESSION["Current"] = '';
// Email Sessions
if (!isset($SESSION["Name"]))
$SESSION["Name"] = '';
if (!isset($SESSION["Name2"]))
$SESSION["Name2"] = '';
if (!isset($SESSION["Email"]))
$SESSION["Email"] = '';
if (!isset($SESSION["Subject"]))
$SESSION["Subject"] = '';
if (!isset($SESSION["Msg"]))
$SESSION["Msg"] = '';
}
function FindMe()
{
$CookiePresent = 0;
if (isset($COOKIE["Headquarters"]))
{
if($COOKIE["Headquarters"] == "Bananarama")
$CookiePresent = 1;
}
return $CookiePresent;
}
function LogMeX2($conn, $name , $pwd1, $Sector) // E101
{
$Name = md5($name);
$Pwd1 = md5($pwd1);
$ThisSector = $Sector;
$valid = 0;
$sqlValid = $conn->query("SELECT current FROM LIBusersX WHERE UserKey = '$Pwd1' AND UserN = '$Name' AND K_Type = 1 AND current > 0");
exit;
$qValid = mysql_query($sqlValid) or die ("E101-100A");
$total = mysql_num_rows($qValid);
if($rows === FALSE) die('E101-101B');
//
// echo $sqlValid . "<br>" . $total;
// exit;
if($total == 0)
$ret = 0;
if($total > 1)
$ret = -1;
if($total == 1)
$ret = 1;
if($ret == 1)
{
$ret = 0;
$rs = mysql_fetch_array($qValid) or die ("E101-100B");
$temp = $rs['current'];
if($temp < 99)
{
$temp -= 1;
$update = "UPDATE LIBusersX SET current = $temp WHERE UserKey = '$Pwd1' AND UserN = '$Name' AND K_Type = 1";
echo $update;
exit;
$result = mysql_query($update);
}
$sqlUser = "SELECT User FROM LIBusersX WHERE UserKey = '$Pwd1' AND UserN = '$Name'";
$qUser = mysql_query ($sqlUser) or die ("E101-100C");
$rs = mysql_fetch_array($qUser) or die ("E101-100D");
// Checl valid sector
$ThisUser = $rs['User'];
$ValidSector = "SELECT * FROM LibSectors WHERE User = '$ThisUser' AND SectorMarker = '$ThisSector'";
$qValid = mysql_query($ValidSector) or die ("E101-100E");
$total = mysql_num_rows($qValid);
if($total > 0)
$ret = $ThisUser;
}
return $ret;
}
?>
``