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

  • Home
  • SEARCH
  • 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 8461959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:01:36+00:00 2026-06-10T14:01:36+00:00

I am learning mysqli. I am trying to fetch data from a table tbllogin.

  • 0

I am learning mysqli.

I am trying to fetch data from a table “tbllogin”.

      //DATABASE CONNECTION

      $hostname="p:localhost";
      $database="dbLogin";
      $username="user1";
      $password="pwd1";



      $mysqli = new mysqli($hostname, $username, $password,$database);

      if(mysqli_connect_errno()){

       echo mysqli_connect_error();

      }

      // Create Query
      $query = "SELECT * FROM tbllogin";


      // Escape Query

      $query = $mysqli->real_escape_string($query);
      echo $query;

      // Execute Query

      if($result = $mysqli->query($query)){

          print_r($result);

          while($row = $mysqli->fetch_object($result)){

              echo $row->column;

          }

          //Free result set
          $result->close();

      }



      ?>

But $mysqli->fetch_object($result) is not working. The if statement containing $mysqli->fetch_object($result) does not execute. I cannot identify if there is any error.

Please help.
Also, suggest whether mysqli procedural form is better or object-oriented form?

Thanks in advance.

  • 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-10T14:01:38+00:00Added an answer on June 10, 2026 at 2:01 pm

    Shouldn’t that be $result->fetch_object() ?

    http://php.net/manual/en/mysqli-result.fetch-object.php

    From Example 1:

    if ($result = $mysqli->query($query)) {
    
        /* fetch object array */
        while ($obj = $result->fetch_object()) {
            printf ("%s (%s)\n", $obj->Name, $obj->CountryCode);
        }
    

    According to the answers on this stackoverflow page, there is not much of a difference between the two.

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

Sidebar

Related Questions

i am trying to add and delete records(games) from my database using jquery and
I am trying to store the dates and month name from my database in
I'm just learning PHP and am trying the most basic thing: capturing info from
I'm learning grails from the book Grails In Action and I'm trying to run
I am trying to do the following... select all columns from the table hqfjt_chronoforms_data_addemailtemplate
I'm still learning more interesting details about PHP. Example: Moving from MySQL to MySQLi.
Simple stuff, I am learning URLs/Networking in my class and I am trying to
I'm learning mysql and have been trying to get this working, but an error
I am learning mysql and ran into a problem with 'mysql.proc' missing when trying
Still learning the MySQL ropes and I'm trying to find out how to do

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.