473,385 Members | 1,930 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

ms and odbc - only returns half the rows

Hi,

I'm attempting to fetch all the data from an MS Access database, but every
time I try with any query it only returns every second row..

I could rows numbered from 1 to 4000 and it would return exactly 2000 rows..
I would get rows 2, 4, 6, 8, 10 ,etc..

This is the code I am using:

$dsn = "DRIVER=Microsoft Access Driver (*.mdb); DBQ=c:\\mdb\\data.mdb;";
$myDB = odbc_connect($dsn,'Admin','') or die (odbc_error());

$query = 'SELECT * FROM Hist_data';
$result = odbc_exec($myDB, $query);
$output = array();

while (odbc_fetch_row($result)){
$output[] = odbc_fetch_array($result);
}

print "Results of your query:\n\n";
print_r($output);

I tried firing up MS access and running exactly the same query, but that
functions normally and returns all the rows, so I'm assuming this is a PHP
bug..

Chris
Jan 3 '07 #1
2 1712
See below:

Skeleton Man wrote:
Hi,

I'm attempting to fetch all the data from an MS Access database, but every
time I try with any query it only returns every second row..

I could rows numbered from 1 to 4000 and it would return exactly 2000 rows..
I would get rows 2, 4, 6, 8, 10 ,etc..

This is the code I am using:

$dsn = "DRIVER=Microsoft Access Driver (*.mdb); DBQ=c:\\mdb\\data.mdb;";
$myDB = odbc_connect($dsn,'Admin','') or die (odbc_error());

$query = 'SELECT * FROM Hist_data';
$result = odbc_exec($myDB, $query);
$output = array();
------------------------------------------------------
while (odbc_fetch_row($result)){
$output[] = odbc_fetch_array($result);
}
--------------------------------------------------------
This is the offending code. Your code fetches the result twice.
you should write something like:

while($temp = odbc_fetch_array($result)) $output[] = $temp;
>
print "Results of your query:\n\n";
print_r($output);

I tried firing up MS access and running exactly the same query, but that
functions normally and returns all the rows, so I'm assuming this is a PHP
bug..

Chris

Jan 3 '07 #2
>------------------------------------------------------
>while (odbc_fetch_row($result)){
$output[] = odbc_fetch_array($result);
}
--------------------------------------------------------
This is the offending code. Your code fetches the result twice.
you should write something like:
>while($temp = odbc_fetch_array($result)) $output[] = $temp;
Thanks, must've been a brain fart I think ;-)

Chris
Jan 3 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: jarednevans | last post by:
I need to know why MS Access/ODBC is reporting different results than the one shown in psql. I created a very simple function below: ------------------ CREATE OR REPLACE FUNCTION...
4
by: Roger Redford | last post by:
Dear Experts, I'm attempting to marry a system to an Oracle 817 datbase. Oracle is my specialty, the back end mainly, so I don't know much about java or javascript. The system uses javascript...
2
by: Indiana Epilepsy and Child Neurology | last post by:
Before asking this questions I've spent literally _years_ reading (Meyer, Stroustrup, Holub), googling, asking more general design questions, and just plain thinking about it. I am truly unable to...
5
by: Todd Huish | last post by:
I have noticed something disturbing when retrieving datasets over a relatively slow line (multiple T1). I am looking at about 25 seconds to retrieve 500 rows via a php-odbc link. This same select...
7
by: Richard Marsden | last post by:
(also posted to microsoft.public.access.odbcclientsvr but no reply so far: problem concerns ODBC->MS Access) I have some ODBC code that I'm testing against various underlying databases. The...
2
by: Crazy Cat | last post by:
Hi all, I am having trouble getting linked Oracle 9 server in MS SQL Server 2005 Express to work properly. My machine is running Windows XP. The Microsoft and Oracle OLE DB Providers have...
12
by: robertino | last post by:
Hi all, I've put together a few SPs to produce a BOM (bill of materials) listing, which together use a couple of global temp tables, and return the results from a cursor. Here's the code: ...
9
by: 2DIL | last post by:
hello all experts, basically, i have a very small project, in which 97% of the work is complete. yet there is an issue which i cannot solve and i have no error to indicate what the problem...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.