note 78043 deleted from function.mysql-field-table by nlopess

From: Date: Fri, 19 Oct 2007 12:12:08 +0000
Subject: note 78043 deleted from function.mysql-field-table by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-131539@lists.php.net to get a copy of this message
Note Submitter: PoMdaPiMp ---- In the official example, there is a mistake. <?php [...] $table = mysql_field_table($result, 'name'); [...] ?> The last argument is here a string and not the integer expected by the function. Indeed, in the synopsis, the two arguments' types are : result and integer. Here is an other little example that corrects the mistake and give another use of the function. <?php // Build a very easy request $query = "SELECT account.*, country.* FROM account, country WHERE country.name LIKE '%france%' AND account.country_id = country.id"; // Gets the result from the DB $result = mysql_query($query); // Lists the table name and then the field name for ($x = 0; $x < mysql_num_fields($result); $x++) { $str = mysql_field_name($result, $x); print ('<b>' . mysql_field_table($result, $x) . '</b>: ' . $str . '<br />'); } ?> In this little code, the offset is given to mysql_field_name as the second argument.

« previous php.notes (#131539) next »