note 78043 added to function.mysql-field-table
| From: | PoMdaPiMp at osu1 dot php dot net | Date: | Tue, 25 Sep 2007 11:49:58 +0000 |
| Subject: | note 78043 added to function.mysql-field-table | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-130778@lists.php.net to get a copy of this message | ||
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.
----
Server IP: 194.246.101.61
Probable Submitter: 62.23.193.34
----
Manual Page -- http://www.php.net/manual/en/function.mysql-field-table.php
Edit -- https://master.php.net/note/edit/78043
Del: integrated -- https://master.php.net/note/delete/78043/integrated
Del: useless -- https://master.php.net/note/delete/78043/useless
Del: bad code -- https://master.php.net/note/delete/78043/bad+code
Del: spam -- https://master.php.net/note/delete/78043/spam
Del: non-english -- https://master.php.net/note/delete/78043/non-english
Del: in docs -- https://master.php.net/note/delete/78043/in+docs
Del: other reasons-- https://master.php.net/note/delete/78043
Reject -- https://master.php.net/note/reject/78043
Search -- https://master.php.net/manage/user-notes.php