You are here: Re: ms and odbc - only returns half the rows « PHP Programming Language « IT news, forums, messages
Re: ms and odbc - only returns half the rows

Posted by Hendri Kurniawan on 01/03/07 04:46

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
>
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация