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 3992084
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:43:24+00:00 2026-05-20T06:43:24+00:00

Here is the MYSQLi code: public function display() { $sql = SELECT title, date_posted,

  • 0

Here is the MYSQLi code:

  public function display() {
    $sql = "SELECT title, date_posted, text, url
              FROM notes ORDER BY date_posted DESC
              LIMIT ?, ?";
    $results = $this->query($sql, "ii",
                              $this->page_offset,
                              $this->notes_per_page);
    $results = $this->db->store_result();
    while ($row = $results->fetch_row()) {
      var_dump($row);
    }
    //$this->write($results);
  }

  // this is the $this->db->query() function referred to above.
  public function query() {
    $args = func_get_args();
    $statement = $this->db->prepare($args[0]);
    $args = array_slice($args, 1);
    call_user_func_array(array($statement, 'bind_param'), &$args);
    $statement->execute();
    return $statement;
  }

The MYSQL table:

mysql> desc notes;
+-------------+--------------+------+-----+---------+----------------+
| Field       | Type         | Null | Key | Default | Extra          |
+-------------+--------------+------+-----+---------+----------------+
| id          | int(11)      | NO   | PRI | NULL    | auto_increment |
| date_posted | date         | NO   |     | NULL    |                |
| title       | varchar(255) | NO   |     | NULL    |                |
| text        | longblob     | NO   |     | NULL    |                |
| url         | varchar(255) | NO   |     | NULL    |                |
+-------------+--------------+------+-----+---------+----------------+

A sample row:

mysql> SELECT title, url, date_posted FROM notes WHERE url='init';
+-------+------+-------------+
| title | url  | date_posted |
+-------+------+-------------+
| init  | init | 2011-02-16  |
+-------+------+-------------+
1 row in set (0.00 sec)

The output for the corresponding row. What in the world…?:

array(4) { [0]=> string(0) “” [1]=>
string(0) “” [2]=> string(4) “init”
[3]=> string(4) “�” }

If I switch fetch_array() to fetch_object(), I get this:

object(stdClass)#3 (4) { [“title”]=>
string(0) “” [“date_posted”]=>
string(0) “” [“text”]=> string(4)
“init” [“url”]=> string(4) “�” }

Thank you for all and any help/suggestions/comments!

New observation:

Adding another column to the query outputs a new column (the wrong one again though). So for example, if:

// and yes, I do realize that I am repeating 'url',
// and I have no clue why this is happening.
$sql = "SELECT title, date_posted, text, url, url
              FROM notes ORDER BY date_posted DESC
              LIMIT ?, ?";

Then the output row is:

array(5) { [0]=> string(0) “” [1]=>
string(0) “” [2]=> string(4) “init”
[3]=> string(4) “�” [4]=>
string(350) “

This is the text for the init article. I cut it short for the sake of brevity in this stackoverflow question
” }

  • 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-05-20T06:43:25+00:00Added an answer on May 20, 2026 at 6:43 am
    
        public function display() {
        $sql = "SELECT title, date_posted, text, url
                  FROM notes ORDER BY date_posted DESC
                  LIMIT ?, ?";
        $results = $this->query($sql, "ii",
                                  $this->page_offset,
                                  $this->notes_per_page);
        var_dump($results);
      }
    
    
    
     public function query() {
        $args = func_get_args();
        $statement = $this->db->prepare($args[0]);
        $args = array_slice($args, 1);
        call_user_func_array(array($statement, 'bind_param'), &$args);
        $statement->execute();
        $return = array();
    $statement->store_result();
    $row=array();
    $data = $statement->result_metadata();
    $fields = array();
    $fields[0] = &$statement;
    while($field = $data->fetch_field()) {
    $fields[] = &$row[$field->name];
    }
    call_user_func_array("mysqli_stmt_bind_result", $fields);
    
    $i = 0;
    while ($statement->fetch()) {
    foreach ($row as $key1=>$value1) $return[$i][$key1] = $value1;
    $i++;
    }
    $statement->free_result();
    return $return;
    
    
      }
    
    
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got the following function: public function already_tweeted($tweet){ return mysql_num_rows(mysql_query(SELECT * FROM `retweeted` WHERE
Here I have some function to read my table <?php public function get_all_record($table, $fields
Here is my code, which takes two version identifiers in the form 1, 5,
OK, so this is leading on from another question I asked here recently. Basically,
Here, i have coded to get data from DB. I want to store the
<?php class ann { public function __construct($context, $orgs_id, $created_at) { $this->context = $context; $this->orgs_id
I'm the second dev and a recent hire here at a PHP/MySQL shop. I
I've updated php.ini and moved php_mysql.dll as explained in steps 6 and 8 here.
I'm having some trouble updating a row in a MySQL database. Here is the
Pretty straightforward stuff, here -- I'm just not good enough with mysql to understand

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.