mysql_data_seek() Offset 3 is invalid error

I am trying to pull content from a database into a table format. At first it was repeating the same results in both columns, so I changed the code a little. Now it seems to only work when there are an even number of results because if it finds a third one, it also wants to put something in the 4th spot.

ERROR IS:
Warning: mysql_data_seek() [function.mysql-data-seek]: Offset 3 is invalid for MySQL result index 3 (or the query data is unbuffered) in \HOSTING\DFS\20\6\9\9\2002195996\user\sites\winegard.com\www\videos\misc.inc.php on line 32
Cannot seek to row 3:

LINE 32 IS:
if (!mysql_data_seek($result, ++$i))

FULL CODE IS:

<? //* FUNCTION TO DISPLAY LINKS function query_sql9($sql, $type) { if(!$result = mysql_query($sql)) { print "There was an error in sql statement, ".mysql_error()."
$sql"; } elseif(mysql_num_rows($result)==0) { print 'There are no records found!

'; } else { for ($i = 0; $i <= mysql_num_rows($result)-1; $i++) { if (!mysql_data_seek($result, $i)) { echo "Cannot seek to row $i: " . mysql_error() . "\n"; continue; } if(!($row = mysql_fetch_object($result))) { continue; } if (!mysql_data_seek($result, ++$i)) { echo "Cannot seek to row $i: " . mysql_error() . "\n"; } $rowTwo = mysql_fetch_object($result); print ''; if($rowTwo != 0) { print ''; } else { print ''; } } } } //* END FUNCTION TO DISPLAY LINKS //* START DATABASE QUERY FOR SEARCH { $sql = ' SELECT * from videos2 WHERE category=\'MISC\' ORDER BY date DESC'; query_sql9($sql, $_POST["kb_query"]); } ?>
'.$row->title.'
'.$row->description.'
'.$rowTwo->title.'
'.$rowTwo->description.'


You could change the line:
[php] if (!mysql_data_seek($result, ++$i))[/php]

to:
[php] if ($i+1 <= mysql_num_rows($result) && !mysql_data_seek($result, ++$i))[/php]

YES! Just like you said but with the “-1” worked perfectly! Thanks!!

if ($i+1 <= mysql_num_rows($result)-1 && !mysql_data_seek($result, ++$i))

Sponsor our Newsletter | Privacy Policy | Terms of Service