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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:02:43+00:00 2026-06-11T17:02:43+00:00

Good eve everyone! For some reason Database::fetchArray() is skipping the first $row of the

  • 0

Good eve everyone!

For some reason Database::fetchArray() is skipping the first $row of the query result set.

It prints all rows properly, only keeps missing out the first one for some reason, I assume there’s something wrong with my fetchArray() function?

I ran the query in phpMyAdmin and it returned 4 rows, when I tried it on my localhost with the php file (code below) it only printed 3 rows, using the same ‘WHERE tunes.riddim’-value ofcourse. Most similiar topics on google show that a common mistake is to use mysql_fetch_array() before the while(), which sets the pointer ahead and causes the missing of the first row, unfortunately I only have one mysql_fetch_array() call (the one within the while()-head).

<?php 

    $db->query("SELECT " .
                "riddims.riddim AS riddim, " .
                "riddims.image AS image, " .
                "riddims.genre AS genre, " .
                "tunes.label AS label, " .
                "tunes.artist AS artist, " .
                "tunes.tune AS tune, " .
                "tunes.year AS year," .
                "tunes.producer AS producer " .
                "FROM tunes " . 
                "INNER JOIN riddims ON tunes.riddim = riddims.riddim " .
                "WHERE tunes.riddim = '" . mysql_real_escape_string(String::plus2ws($_GET['riddim'])) . "'" .
                "ORDER BY tunes.year ASC");

    $ar = $db->fetchArray();

    for($i = 0; $i < count($ar) - 1; $i++)
    {
        echo $ar[$i]['riddim'] . " - " . $ar[$i]['artist'] . " - " . $ar[$i]['tune'] . " - " . $ar[$i]['label'] . " - " . $ar[$i]['year'] . "<br>";
    }

?>

Database::fetchArray() looks like:

public function fetchArray()
{

    $ar = array();

    while(($row = mysql_fetch_array($this->result)) != NULL)
        $ar[] = $row;

    return $ar;
}

Any suggestions appreciated!

  • 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-11T17:02:44+00:00Added an answer on June 11, 2026 at 5:02 pm

    You should remove -1 from the for loop

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

Sidebar

Related Questions

Good day everyone, I'm an independent game developer who has, in the past, primarily
Good afternoon all, I am building a function that takes a string as input,
Good afternoon to all, I have this scenario: I am using SQL Server 'BulkInsert'
Good day, I have a gen_server process which does some long-running state-updating tasks periodically
Good evеning! echo date('r', strtotime('10.01.11')); Prints: Sun, 05 Feb 2012 10:01:11 Expected: Mon, 10
Good mor(eve)ning guys. My question is a bit general: How can I adapt any
Good day. Having read about Model 2 architecture I got confused about some points.
Good day everyone. I'm trying to figure out a way to use multiple flags
Good day. I'm confused about storing the embedded database in a Java EE application.
Good day everyone, I have the following XML data : <?xml version=1.0 encoding=utf-8 ?>

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.