Offset 0 is not valid for MySQL 64 result index (or query data not loaded)

I work with php and mysql and suddenly get

mysql_data_seek () [function.mysql-data-seek]: offset 0 is not valid for the MySQL 64 result index (or query data is not loaded)

What does it mean.

I don’t know where to start debugging this one.


This class is passed by the mysql resource to the constructor.
class dbResult { private $result; private $num_rows; function __construct($result) { $this->result = $result; } function result($type = 'object') { @mysql_data_seek($this->result, 0); if ($type == 'array') return mysql_fetch_assoc($this->result); if ($type == 'object') { if ($this->num_rows() == 1) { $data = new stdClass(); foreach (mysql_fetch_assoc($this->result) as $k => $v) $data->$k = $v; return $data; } if ($this->num_rows() > 1) { $data = array(); while ($result = mysql_fetch_assoc($this->result)) { $row = new stdClass(); foreach ($result as $k => $v) $row->$k = $v; $data[] = $row; } return $data; } return false; } } function num_rows() { return mysql_num_rows($this->result); } function num_fields() { return mysql_num_fields($this->result); } } 
+8
php mysql
source share
1 answer

if the result set is empty mysql_data_seek() will E_WARNING with E_WARNING . I think this happens in your case because you are not checking if the result set is empty or not before calling mysql_data_seek() .

Always check the result for the number of rows, if they are> = 1, then you can call mysql_data_seek()

+10
source share

All Articles