Jump to content

Recommended Posts

Hello all.   I am using a premade login script which has some very powerful function built in, the one I am looking at using is as follows:

  /** 
    * query - Performs the given query on the database and 
    * returns the result, which may be false, true or a 
    * resource identifier. 
    */ 
   function query($query){ 
      return mysqli_query( $this->connection, $query); 
   } 

The issue is, displaying the results.  I call is via the following code:

$database->query('SELECT LastName, Firstname FROM Patrons WHERE LastName = "Delude"');

But I have no idea how to display it.  I have attempted to echo it out, but I get the following error in the logs:

 

PHP Catchable fatal error:  Object of class mysqli_result could not be converted to string

 

 

Link to comment
https://forums.phpfreaks.com/topic/290827-how-can-i-get-this-result-of-the-query/
Share on other sites

The function returns a result object. More information can be found here:

http://php.net/manual/en/mysqli.query.php

 

Does the login script have another function for looping through query results? If not, you could create a loop like you would do for any other query. A loop could be created using mysqli_fetch_assoc(), for example:

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.