mysql_fetch_assoc

From: Date: Fri, 05 Sep 2003 18:54:19 +0000
Subject: mysql_fetch_assoc
Groups: php.doc 
Request: Send a blank email to phpdoc+get-969356208@lists.php.net to get a copy of this message
Hi, I found odd thing about this function (or maybe even a bug). I tried to reach http://bugs.php.net but it was down all the time. Let's imagine that I have MySQL-command to generate table CREATE TABLE tbl ( datefield DATETIME ); INSERT INTO tbl VALUES ('2003-03-03 11:11:11'), ('2003-04-04 11:11:11'), ('2003-05-05 11:11:11'), ('2003-05-05 11:11:11'); and code looking like this <?php // Everything about MySQL connecting has been done $result = mysql_query("SELECT DATE_FORMAT(datefield, '%d.%m.%Y') FROM tbl"); while ($row = mysql_fetch_assoc($result) { echo "{$row['datefield']}\n"; } /* Output nothing */ // New try with mysql_fetch_row $result = mysql_query("SELECT DATE_FORMAT(datefield, '%d.%m.%Y') FROM tbl"); while ($row = mysql_fetch_row($result) { echo "{$row['0']}\n"; } /* Output 03.03.2003 04.04.2003 05.05.2003 06.06.2003 */ ?> There might be some syntax errors, I just tried to make example as simple as possible. Anyway, if I don't use DATE_FORMAT before datefield, mysql_fetch_assoc works fine. Sorry my english, I haven't been using it for a while. Sincerely yours Jouni Tuovinen

« previous php.doc (#969356208) next »