Jump to content

mlj0102

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Everything posted by mlj0102

  1. I get this error when I run the query: and I have no idea how to fix.. I have been staring at this for days. Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, null given in /onlinebanking/viewtransactions.php on line 65 This is my view transactions page <?php //viewtransaction require_once('../websiteconfig.inc.php'); require_once(ABSOLUTE_PATH . 'class/database.class.php'); require_once(ABSOLUTE_PATH . 'class/person.class.php'); require_once(ABSOLUTE_PATH . 'class/bankaccount.class.php'); /*START SESSION*/ session_start(); $currentMember = unserialize($_SESSION['currentMember']); $currentMember->connection = $conn; /*Database*/ $db = new Database; $conn = $db->connection; $bank_account = $_GET['q']; ?> </div> <link href="../_assets/stylesheets/css_dd_bankingnav.css" rel="stylesheet" type="text/css" /> <link href="../_assets/stylesheets/style.css" rel="stylesheet" type="text/css" /> <div class="container" id="shadow"> <div> <?php include(ABSOLUTE_PATH . 'header.inc.php'); ?> <div> <h1 class="body" align="center">Accounts</h1> <?php include(ABSOLUTE_PATH . 'onlinebanking/onlinebankingnav.inc.php'); ?> <table id="accounts" summary="Bank Account Balance Information" border="3" align="center"> <thead> <tr> <th bgcolor="#CCCCCC">Account ID</th> <th bgcolor="#CCCCCC">Transaction Date</th> <th bgcolor="#CCCCCC">Transaction Type</th> <th bgcolor="#CCCCCC">Transaction Amount</th> <th bgcolor="#CCCCCC">Current Balance</th> </tr> </thead> <tbody> <?php $bankaccount = new Bankaccount($account['BankAccountID']); $bankaccount->connection = $conn; /*Loop thorugh account - Grabs data*/ while($transaction = mysqli_fetch_assoc($transactionbalance)) { $transactionbalance = $bankaccount->retrieve_transactions($transaction['BankAccountID']); //looks for account data $querydata = mysqli_num_rows($transactionbalance); //Looks for transcations if ($querydata == 0) { echo ('There is no transaction history on this account'); } else { } echo '<tr>' . "\n"; echo "\t" . '<td>' . $transaction['BankAccountID'] . '</td>' . "\n"; echo "\t" . '<td>' . $accounttype['TransactionDate'] . '</td>' . "\n"; echo "\t" . '<td>' . $accounttype['TransactionType'] . '</td>' . "\n"; echo "\t" . '<td>$' . number_format($accounttype['TransactionAmount'], 2) . '</td>' . "\n"; echo "\t" . '<td>$' . number_format($transaction['CurrentBalance'], 2) . '</td>' . "\n"; echo '<tr>' . "\n"; } /*Close DB*/ mysqli_close($db->connection); ?> </tbody> </table> <br> </div><!--End of main content--> <?php include(ABSOLUTE_PATH . 'footer.inc.php'); ?> </div><!--end of header--> This is my bankaccount.class page <?php /*Bankaccount Class*/ class Bankaccount { /*attributes for the first and last name of the class*/ private $accountid; private $memberid; private $accounttypeid; private $accounttypename; public $connection; /*Constructs the function*/ function __construct($accountid, $accounttypeid){ $this->accountid = $accountid; $this->accounttypeid = $accounttypeid; } //end constructor /*Destroys the function*/ function __destruct(){ } //ends destructor /*Get funtion*/ public function __get($name) { return $this->$name; } // Ends get funtction /*Use the set function*/ public function __set($name, $value) { $this->$name=$value; } //End set function /*This is what retrieves the values from memmory*/ public function retrieve_current_balance() { $balance_query = "SELECT CurrentBalance UserID FROM BankAccount WHERE BankAccountID = " . $this->accountid . " LIMIT 0,1"; $result = mysqli_query($this->connection, $balance_query); return $result; } This is the part of my bankaccount.class that actually involves viewing my transactions <?php //query for transactions public function retrieve_transactions() { $transaction_query = "SELECT tl.TransactionDate, tt.TransactionType, tl.TransactionAmount FROM TransactionLog tl INNER JOIN TransactionType tt ON tl.TransactionTypeID = tt.TransactionTypeID WHERE BankAccountID = " . $this->accountid . " LIMIT 0,1"; $result = mysqli_query($this->connection, $transaction_query); $db_array = mysqli_fetch_array($results); return $result; } ?> <?php /*Function validates user account for user ID*/ public function validate_useraccount(){ $account_query = "SELECT UserID FROM BankAccount WHERE UserID = " . $this->accountid; $results = mysqli_query($this->connection, $account_query); $db_array = mysqli_fetch_array($results); $return_value = 1; if(count($db_array()) < 1) { $return_value = 0; } return $return_value; } /*Deposit*/ public function deposit($UserID=0, $BankAccountID=0, $DepositAmount=0){ $getbalance = mysqli_fetch_assoc($this->retrieve_current_balance()); $currentbalance = $getbalance['CurrentBalance']; $today = date('Y-m-d', mktime()); /*Deposit Funds*/ $newbalance = $currentbalance + $DepositAmount; $deposit = mysqli_query($this->connection, "UPDATE BankAccount SET CurrentBalance = $newbalance WHERE BankAccountID = $BankAccountID"); if($deposit){ //transaction completed /*Update Transaction log*/ $log_query = "INSERT INTO TransactionLog (TransactionTypeID, BankAccountID, UserID, TransactionAmount, TransactionDate) VALUES (1, $BankAccountID, $UserID, $DepositAmount, $today')"; mysqli_query($this->connection, $log_query); } /*New Balance*/ return $newbalance; } } //End of class ?>
  2. I believe all functions are public unless nested and you should declare the type of function public or private.
  3. I have an issue I am not sure how to solve. What I want to do is to make sure authentication has already occurred . Or that my $currentMember is set and it if is set for an IF statement to do nothing.. However it it is not set for a redirect to the home page with no echo statements or anything to that nature just a redirect. Am I even close? <?php include( ABSOLUTE_PATH . 'class/database.class.php' ); include( ABSOLUTE_PATH . 'class/person.class.php' ); //Start Session session_start(); $currentMember = unserialize($_SESSION['currentMember']); $db = new Database; $person = new Person($currentMember->memberid); if ( $auth_satus == 0 ) { header('Location:' . APP_ROOT . 'index.php'); } exit(); ?>
  4. I am trying to echo out an array from my data base. I think I have my function created correctly: Noted below is the snippet from my transaction.class.php file <?php //Retreives data from the database public function retrieve_all_data($TransactionDate=0, $TransactionType=0, $TransactionAmount=0, $CurrentBalance=0){ $accounts_query = "SELECT TransactionDate, TransactionType, TransactionAmount, CurrentBalance FROM BankAccount, TransactionType, TransactionLog = " . $this->accountid ." LIMIT 0,30"; $result = mysqli_query($this->connection, $accounts_query); return $result; } ?> I try to echo out using this format but I am not having any luck. <?php /*Accounts*/ $currentMember->connection = $conn; $accounts = $currentMember->retrieve_all_data(); /*Loop through account - Grabs data*/ while($account = mysqli_fetch_assoc($accounts)){ /*Retrieve Balance*/ $transaction = new Transaction($account['TransactionDate'], $account['TransactionType']); $transaction->connection = $conn; //$balance = mysqli_fetch_assoc($transaction->retrieve_current_balance()); echo '<tr>' . "\n"; echo "\t" . '<td>' . $account['TransactionDate'] . '</td>' . "\n"; echo "\t" . '<td>' . $account['TransactionType'] . '</td>' . "\n"; echo '<tr>' . "\n"; } /*Close DB*/ mysqli_close($db->connection); ?>
  5. I am having problems with a line of code. This is what I have so far. I am missing a "," according to my error message. Im trading in deep water with this line of code. I am trying to use the data from my echo state to be a hyperlink... If that makes sense. echo "\t" . '<td><a href="' . APP_ROOT . 'onlinebanking/viewtransactions.php">. $account['BankAccountID'] . </a>' '</td>' . "\n";
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.