Jump to content

How can I get this result of the query?


Lostnode

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:

 

  Quote
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

Archived

This topic is now archived and is closed to further replies.

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