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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:25:34+00:00 2026-06-06T19:25:34+00:00

I open my sq3d fine, but when I try to do a SELECT on

  • 0

I open my sq3d fine, but when I try to do a SELECT on one of my tables it seems to not return the results I excpect. Here is the php code:

$buildingArray = array();

class MyDB extends SQLite3
{
function __construct()
{
    $this->open('Database.s3db');
}
}


$db = new MyDB();

$query1 = "SELECT * FROM tbl_uploadData";
$result1 = $db->query($query1);
$u = $result1->fetchArray();
echo "<br/>Size of u: ".sizeOf($u)."<br/>";

for($i=0; $i<sizeOf($u); $i++){
echo "<br/>Items: ".$u[$i]."<br/>";
}

This is what is in my Database:

tbl_uploadData : b_id – 1,2,3,4 : where 1,2,3,4 are the items within the fields, b_id the field name and tbl_uploadData the table.

I expect to get 1, 2, 3 and 4 to return in the fetchArray()

All i get in return is:

Size of u: 2
Items: 1
Notice: Undefined offset: 1 in C:\xampp\htdocs\PHPexcel\Tests\StrategicExcel.php on line 72
Items: 
  • 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-06T19:25:35+00:00Added an answer on June 6, 2026 at 7:25 pm

    Here is the solution, as spaced monkey mentioned, fetchArray() only returns one result at a time. So by adding a while loop and a couple of references to my b_id, it should work. I’ve modified my code to:

    $databaseName = "Database.s3db";
    
    $db2 = new SQLite3($databaseName); 
        $sql = "SELECT b_id FROM tbl_uploadData"; 
        $result = $db2->query($sql);//->fetchArray(SQLITE3_ASSOC); 
        $row = array(); 
    
        $i = 0; 
         while($res = $result->fetchArray(SQLITE3_ASSOC)){ 
             if(!isset($res['b_id'])) continue; 
                $row[$i]['b_id'] = $res['b_id']; 
                $i++; 
          } 
          print_r($row); 
    

    Hope this helps if anyone comes across this problem in the future, TY

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

Sidebar

Related Questions

Open Ankh seems to be using Subversion 1.6.2 and Tortoise uses Subversion 1.6.0. After
I open several files in Vim by, for example, running vim a/*.php which opens
open() fails with ENOENT (no such file or directory) on first attempt but works
Open Source PHP script for HTTP video streaming? I need some PHP script or
Open Source PHP script for HTTP streaming? Does anyone know something about such things?
open Visual Studio 2010. Click File->New->Web Site... In the dialog window that opens, select
Open this site in IE8 (not sure about 7) http://www.koffeebreak.info/ See how the main
Open the following page in IE7 and try clicking on the image within the
# Open new file to write file = None try: file = open(filePath, 'w')
When open a perspective, i want to show two editors in different floders. But

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.