PHP mysql_fetch_lengths() function
Definition and Usage
The mysql_fetch_lengths() function retrieves the length of each field in a row.
The rows are returned by these functions:mysql_fetch_array(),mysql_fetch_assoc(),mysql_fetch_object() or mysql_fetch_row().
If successful, this function returns an array of numbers. If an error occurs or there are no other rows, it returns false.
syntax
mysql_fetch_lengths(data)
Parameter | Description |
---|---|
data | Required. The data pointer to use. The data pointer is from mysql_query() The returned results. |
Example
<?php $con = mysql_connect("localhost", "peter", "abc123"); if (!$con) { die('Could not connect: ' . mysql_error()); } $db_selected = mysql_select_db("test_db",$con); $sql = "SELECT * from Person WHERE Lastname='Refsnes'"; $result = mysql_query($sql,$con); print_r(mysql_fetch_row($result)); print_r(mysql_fetch_lengths($result)); mysql_close($con); ?>
Output:
Array ( [0] => Adams [1] => John [2] => London ) Array ( [0] => 5 [1] => 4 [2] => 6 )