|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-07-08 08:05 UTC] john at ceressoft dot nl
Description:
------------
when fetching data with sqlite_fetch_array as an assioative array, the data and names mixes wrong up.
Output from print_r:
{0] =>
[time] => 1057663053
[app] => OLAF
[user] => Pakhuis administratie
[msg] => login, new session
As you can see, columns app and user are exchanged
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 03:00:01 2025 UTC |
Tested this bug with php5beta2 and the problem does not exist any longer, if it did in the beginning. test script follows... <?php /* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # #SQLite Admin Structure Dump for table testtable # CREATE TABLE testtable (fone VARCHAR(99) NOT NULL DEFAULT 'blah', ftwo VARCHAR(3) NOT NULL DEFAULT 'blahblah', fthree VARCHAR(99) NOT NULL DEFAULT '') # ### SQLite Admin Data Dump for table testtable # INSERT INTO testtable ( one, two, three); INSERT INTO testtable ( one2, two2, three3); INSERT INTO testtable ( one3, two3, three3); INSERT INTO testtable ( one4, two4, three4); INSERT INTO testtable ( one5, two5, three5); ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ // make sure it is broken error_reporting(E_ALL); // our sql $sql = "SELECT * FROM testtable"; // connect to the db $db = @sqlite_open('test.db', 0666, $sqliteerror); // run the query $res=sqlite_query($db, $sql); // set a counter $i=0; // begin table for layout echo '<table border="1"><tr>'; // get the field names while($i<sqlite_num_fields($res)) { // echo the field names echo '<th>'.sqlite_field_name($res, $i).'</th>'; // increment the counter $i++; } // end the table header row echo '</tr>'; // loop through the ASSOCIATIVE array while($row=sqlite_fetch_array($res, SQLITE_ASSOC)) { // echo out the values echo '<tr><td>'.$row['fone']. '</td><td>'.$row['ftwo'].'</td><td>'.$row['fthree'].'</td></tr>'; } // end of table echo '</table>'; ?>