PHP 7.4.0RC2 Released!


(PHP 4, PHP 5)

mysql_field_seekSet result pointer to a specified field offset


This extension was deprecated in PHP 5.5.0, and it was removed in PHP 7.0.0. Instead, the MySQLi or PDO_MySQL extension should be used. See also MySQL: choosing an API guide and related FAQ for more information. Alternatives to this function include:


mysql_field_seek ( resource $result , int $field_offset ) : bool

Seeks to the specified field offset. If the next call to mysql_fetch_field() doesn't include a field offset, the field offset specified in mysql_field_seek() will be returned.



The result resource that is being evaluated. This result comes from a call to mysql_query().


The numerical field offset. The field_offset starts at 0. If field_offset does not exist, an error of level E_WARNING is also issued.

Return Values

Returns TRUE on success or FALSE on failure.

See Also

add a note add a note

User Contributed Notes 4 notes

adrien dot gibrat at gmail dot com
10 years ago
Not dumb at all!!

It means that "mysql_field_seek" and "mysql_data_seek" are moving the same cursor... through the rows and columns of the result resource.

Also means that the cursor goes to a new row when it reach a final field(aka column), by exemple while looping with "mysql_fetch_field".

Calling "mysql_fetch_object", "mysql_fetch_array", "mysql_fetch_assoc"
and "mysql_fetch_row" seems to place the cursor at the end of the line.

So calling "mysql_fetch_field" without a field index, just after that, will return false.
chris at igwsolutions dot com
11 years ago
I spent a good deal of time trying to get the example to work, but the example does not work.
To do what the exaple is trying to do, you would need to use mysql_data_seek

assume we have table named testing which contains
id      name
1       Hassan
2       Jack
3       Rose

Here is an expample that will do the above example.

Since I am more comfortable in a OOP setting, I used mysql_fetch_object

$sql="SELECT  * from testing";

$row = mysql_fetch_object($result);
$row->id . ' ' . $row->name; // Output is (1      Hassan)
$row = mysql_fetch_object($result);
$row->id . ' ' . $row->name; // Output is (3      Rose)
echo "<BR><BR>";
poulpillusion at free dot fr
12 years ago
A dumb comment... but it may save people some time :
mysql_field_seek != mysql_data_seek

In order to fetch again the results of a resource result from the beginning, you will use mysql_data_seek(id, 0)
Hassan Kazem
11 years ago
an example of this function
assume we have table1 which contains
ID      Name
1       Hassan
2       Jack
3       Rose
("", "username", "password") or die(mysql_error());
mysql_select_db("database") or die(mysql_error());
$sql="SELECT  * from table1";
$row = mysql_fetch_array($result);
$row['ID'] . ' ' . $row['Name']; // Output is (1      Hassan)
$row['ID'] . ' ' . $row['Name']; // Output is (3      Rose)
// You can see that the seek command forwarded the pointer one step and skipped row number 2
To Top