Wordpress, mysql_data_seek, external query inside loop
Hey there, why does this code not work?
$qry = mysql_query("SELECT performerid,pic0 FROM ".$table." ORDER BY RAND() LIMIT 6");
$start = new WP_Query('showposts=6&orderby=rand');
if ($start->have_posts()) : while( $start->have_posts() ) : $start->the_post();
$rows = mysql_fetch_assoc($qry);
if (!$rows)
{
mysql_data_seek($rows,0);
$rows = mysql_fetch_assoc($qry);
}
$perfs = $rows['performerid'];
$pics = $rows['pic0'];
I ahve the following error:
Warning: mysql_data_seek(): supplied argument is not a valid MySQL result r开发者_如何学Cesource in /home/content/d/d/a/ddxxxx
Your call to mysql_data_seek only happens if $rows is null. If that's true, then the call to mysql_data_seek will certainly fail, because one of it's required args is null. That's why you're getting the error message.
The problem is you're passing the wrong thing to mysql_data_seek(). It's expecting you to pass it $qry (your results object) and not the empty $rows variable you just tested.
精彩评论