views:

18

answers:

2

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 resource in /home/content/d/d/a/ddxxxx
+1  A: 

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.

Dylan West
mysql_data_sweeek, I'm trying to query the first row again, this is inside a wordpress loop -- in case i have more pots than rows, to query the rows again
webmasters
A: 

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.

infamouse