08-27-2012, 06:57 PM
Its really not that hard to make it in pdo.
Also, if u want to edit that later u will spend hours on tracing back all the variables u used.
<?php
try
{
$db = new PDO('mysql:host=localhost', 'username', 'password');
}
catch
{
die('Unable to connect to the database<br />Please try again later');
}
if( $User->LoggedIn == true )
{
$dbauth = $SiteSQL["config-database_auth"];
$dbsite = $SiteSQL["config-database_site"];
$uid = $User->ID;
$query = sprintf
("
SELECT
u.cash as cash,
l.a_online_time as time
FROM
%s.bg_user u,
%s.t_user_log l
WHERE
u.user_code = :uid
AND
l.a_account_index = u.user_code
", $dbauth,
$dbsite );
$dbh = $db->prepare($query);
$dbh->bindParam(':uid', $uid, PDO:
ARAM_INT);$dbh->execute();
$result = $dbh->fetch();
$cash = $result['cash'];
$time = $result['time'];
if( isset($_POST['change']))
{
$dbh = $db->prepare( sprintf('UPDATE %s.bg_user SET cash = cash + :timepoints WHERE user_code = :uid', $auth));
$dbh->bindParam(':timepoints', $time, PDO:
ARAM_INT);$dbh->bindParam(':uid', $uid, PDO:
ARAM_INT);$dbh->execute();
$dbh = $db->prepare( sprintf('UPDATE %s.t_user_log SET a_online_time = 0 WHERE a_account_index = :uid', $db));
$dbh->bindParam(':uid', $uid, PDO:
ARAM_INT);$dbh->execute();
$cash -= $time;
$time = 0;
}
printf
('
<center>
Your Current Cash Is : %d<br />
Your current online time points : %d<br />
<form id="form1" name="form1" method="post">
<input name="change" value="Time For Cash !" type="submit" />
</form>
</center>
', $cash, $time);
}
else
echo 'Please login to exchange Online Time Points for Cash';
?>

