Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8054143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:05:00+00:00 2026-06-05T08:05:00+00:00

For a school project, I am creating an imaginary online banking site that acessess

  • 0

For a school project, I am creating an imaginary online banking site that acessess a database at school for imaginary account information. Every time I view account I get two mysqli errors. one on line 26 in person.class.php and another on line 52 on veiwaccounts.php I traced the main cause of that error in my person class but can’t seem to fix it in any way. The errors are

Warning: mysqli_query() expects parameter 1 to be mysqli, null given in …/person.class.php on line 26
Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, null given in …/viewaccounts.php on line 52

Here is a sample of some code from the viewaccounts.php file:

if($currentMember)
{
    $currentMember = new Person($memberid);
    $accounts =  $currentMember->retrieve_all_accounts();

    //HERE IS WHERE THE PROBLEM IS $accounts = $currentMember->retrieve_all_accounts(); 

    //Loop through accounts
    while($account = mysqli_fetch_assoc($accounts)) {
        //Retrieve balance
        $bankaccount = new Bankaccount($account['BankAccountID']);
        $bankaccount->connection = $conn;
        $balance = mysqli_fetch_assoc($bankaccount->retrieve_current_balance());

Here is the code for the person class file:

public function retrieve_all_accounts() {
    $accounts_query = "SELECT BankAccountID FROM BankAccount WHERE UserID = " .$this->memberid;
    $result = mysqli_query($this->connection, $accounts_query);
    return $result;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T08:05:01+00:00Added an answer on June 5, 2026 at 8:05 am

    Change

        //Accounts
        $currentMember->connection = $conn;
    
        //instantiating class here since suggested code from video fails to do it.
    
    
    if($currentMember)
    {
        $currentMember = new Person($memberid);
        $accounts =  $currentMember->retrieve_all_accounts();
    
    }else
    {
        echo "<p>not working</p>";
    }
    

    To

    if(!$currentMember) {
      $currentMember = new Person($memberid);
    }
    $currentMember->connection = $conn;
    $accounts =  $currentMember->retrieve_all_accounts();
    

    I would also shift this into the first PHP code block for readability.

    You are instantiating a new Person only if $currentMember evaluates to TRUE – if the unserialize() call fails $currentMember will evaluate to FALSE, and that is when you should create a new object.

    Also you assigned the connection property first, which will be destroyed when you create the new Person, which you are presumably doing every time otherwise you would see more warnings.

    You should also refactor the entire logic that tests whether the Person was saved in the $_SESSION – for a start, sessions will serialize objects themselves so you should not need to call serialize()/unserialize(). What you should do instead is define an __autoload() function and just store the object instance in $_SESSION.

    I also note that your development server seems to have short_open_tag on – turn it off, it is bad practice to use it as it is disabled pretty much everywhere in the real world.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a school project creating a CMS for my portfolio site. I
I have an interest in creating a NoSQL database system for a school project
I'm creating an iOS project for school and it works with chemical reactions. The
For a school project i need to write or use a online programming editor.
For a school project we're developing a game that's a little like Conway's game
For my school project, I would like to build a gui that someone else
I'm creating an RPN calculator for a school project and having trouble with the
I am doing a school project regarding a small website that uses php. I
I'm doing a school project about maintaining a personal Database. but my tutors didn't
I'm creating a registration form on my school project website. I have given a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.