note 74216 added to function.mysql-num-fields

From: Date: Fri, 30 Mar 2007 07:10:22 +0000
Subject: note 74216 added to function.mysql-num-fields
Groups: php.notes 
Request: Send a blank email to php-notes+get-124943@lists.php.net to get a copy of this message
Note that, if you want to get the amount of columns of a table and you're using the "SHOW COLUMNS FROM $table" query, you will have to use mysql_num_rows() instead of mysql_num_fields() on the result. This becomes logical when thinking about it, because the SHOW COLUMNS query returns a result with six columns (Field, Type, Null, Key, Default and Extra) and with a single row for every column found. If you'd count the number of fields, you'd always get 6. If you count the number of rows, you'll get the amount of columns found. ---- Server IP: 194.109.193.76 Probable Submitter: 212.45.52.129 (proxied: unknown) ---- Manual Page -- http://www.php.net/manual/en/function.mysql-num-fields.php Edit -- https://master.php.net/note/edit/74216 Del: integrated -- https://master.php.net/note/delete/74216/integrated Del: useless -- https://master.php.net/note/delete/74216/useless Del: bad code -- https://master.php.net/note/delete/74216/bad+code Del: spam -- https://master.php.net/note/delete/74216/spam Del: non-english -- https://master.php.net/note/delete/74216/non-english Del: in docs -- https://master.php.net/note/delete/74216/in+docs Del: other reasons-- https://master.php.net/note/delete/74216 Reject -- https://master.php.net/note/reject/74216 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#124943) next »