PHP Classes

Data unbuffered?

Recommend this page to a friend!

      Ultimate MySQL  >  All threads  >  Data unbuffered?  >  (Un) Subscribe thread alerts  
Subject:Data unbuffered?
Summary:Offset 0 is invalid for MySQL result
Messages:7
Author:JFive
Date:2008-01-02 21:12:51
Update:2010-04-01 19:51:52
 

  1. Data unbuffered?   Reply   Report abuse  
Picture of JFive JFive - 2008-01-02 21:12:51
I got a lot of warnings like this:

Warning: mysql_data_seek() [function.mysql-data-seek]: Offset 0 is invalid for MySQL result index 1572 (or the query data is unbuffered) in D:\www\pruebas\classes\mysql.class.php on line 1125

I use IIS with PHP Version 5.2.5 (Server API ISAPI)
Mysql Client API version 5.0.45

Please help me.. FOR iterations don't finish

include("classes/mysql.class.php");
$db = new MySQL();

//error_reporting(0);

$abogado = $db->QueryArray("select abog_id, abog_mnue, abog_appa, abog_apma, abog_nomb, abog_finc from cabs_abogado order by abog_appa, abog_apma, abog_nomb");
$total = $db->RowCount();
echo $total." registros<br><br>";
echo "<table border='1'>";
echo "<tr>
<td>Nro</td>
<td>Matricula</td>
<td>Apellidos y Nombres</td>
<td>Domicilio</td>
<td>Telefono</td>
<td>Celular</td>
<td>Estudio</td>
<td>Telefono</td>
<td>Celular</td>
<td>Trabajo</td>
<td>Telefono</td>
<td>Celular</td>
</tr>";
for($i=0;$i<$total;$i++) {
$sql="select abog_id, tigr_id, dire_desc, dire_tele, dire_cell
from cabs_direccion
where abog_id='{$abogado[$i]['abog_id']}'"; // domicilio
$rowdomicilio = $db->QueryArray($sql);

$domicilio=utf8_decode($rowdomicilio[0]['dire_desc']);
$teledomicilio=utf8_decode($rowdomicilio[0]['dire_tele']);
$celldomicilio=utf8_decode($rowdomicilio[0]['dire_cell']);

$estudio=utf8_decode($rowdomicilio[1]['dire_desc']);
$teleestudio=utf8_decode($rowdomicilio[1]['dire_tele']);
$cellestudio=utf8_decode($rowdomicilio[1]['dire_cell']);
-------------------
Excuse my English pls...
$trabajo=utf8_decode($rowdomicilio[2]['dire_desc']);
$teletrabajo=utf8_decode($rowdomicilio[2]['dire_tele']);
$celltrabajo=utf8_decode($rowdomicilio[2]['dire_cell']);

echo sprintf("<tr>
<td>%d</td>
<td>%s</td>
<td>%s %s, %s</td>
<td>%s</td>
<td>%s</td>
<td>%s</td>
<td>%s</td>
<td>%s</td>
<td>%s</td>
<td>%s</td>
<td>%s</td>
<td>%s</td>
</tr>",
$i+1,
$abogado[$i]['abog_mnue'],
$abogado[$i]['abog_appa'],
$abogado[$i]['abog_apma'],
$abogado[$i]['abog_nomb'],
$domicilio,
$teledomicilio,
$celldomicilio,
$estudio,
$teleestudio,
$cellestudio,
$trabajo,
$teletrabajo,
$celltrabajo);

}
echo "</table>";
echo "$i registros impresos";


  2. Re: Data unbuffered?   Reply   Report abuse  
Picture of Jeff Williams Jeff Williams - 2008-01-10 22:37:43 - In reply to message 1 from JFive
Another person had this too and I'm not really sure why. I think it's a configuration thing. I'll do some research and see what I find.

  3. Re: Data unbuffered?   Reply   Report abuse  
Picture of zedron zedron - 2008-12-26 19:03:02 - In reply to message 2 from Jeff Williams
Got any idea why?

Have the same problem.

  4. Re: Data unbuffered?   Reply   Report abuse  
Picture of Bradley Proctor Bradley Proctor - 2009-01-30 14:42:08 - In reply to message 3 from zedron
QueryArray() fails if the query doesn't return any rows

  5. Re: Data unbuffered?   Reply   Report abuse  
Picture of Bradley Proctor Bradley Proctor - 2009-01-30 14:45:38 - In reply to message 4 from Bradley Proctor
Here is my quick fix for the QueryArray function

public function QueryArray($sql, $resultType = MYSQL_BOTH) {
$this->Query($sql);
if (! $this->Error()) {
if ($this->RowCount() > 0) {
return $this->RecordsArray($resultType);
} else {
return array();
}
} else {
return false;
}
}

  6. Re: Data unbuffered?   Reply   Report abuse  
Picture of Dan Dan - 2009-03-04 00:01:48 - In reply to message 2 from Jeff Williams
Hi Jeff,

Any luck with this? I'm getting the same error :-(

Still an awesome class, thanks for all your hard work!

Dan

  7. Re: Data unbuffered?   Reply   Report abuse  
Picture of anto anto - 2010-04-01 19:51:52 - In reply to message 1 from JFive
I'm also using Bradley Proctor approach solution for that kind of problems on function RecordsArray on UMySQL version 2.5. The function became like this :


public function RecordsArray($resultType = MYSQL_BOTH) {
$this->ResetError();
if ($this->last_result) {
// fix error for mysql_data_seek
if ($this->RowCount() > 0) {
if (!mysql_data_seek($this->last_result, 0)) {
$this->SetError();
return false;
} else {
//while($member = mysql_fetch_object($this->last_result)){
while ($member = mysql_fetch_array($this->last_result, $resultType)){
$members[] = $member;
}
mysql_data_seek($this->last_result, 0);
$this->active_row = 0;
return $members;
}
} else {
return false;
}
} else {
$this->active_row = -1;
$this->SetError("No query results exist", -1);
return false;
}
}

And.. still Jeff Williams Umysql class still the best. :)