hola! de nuevo.
Resulta que tengo estos errores pero no se como corregirlos!
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/.humperdink/fiti/midominio.com/ultimos.php on line 45
Warning: Invalid argument supplied for foreach() in /home/.humperdink/fiti/midominio.com/ultimos.php on line 133
la version de mi php es 5 y de mysql tambien
Por favor exenle un ojo al codigo que aqui les muestro haber si me pueden ayudar,, gracias!
Código PHP:
<?
//some kinda OPTIONS
// Uncomment for last active n blogs
//$limit_results=5;
$connection = mysql_connect('XXX', 'XX', 'XX')
or die('No pudo conectarse : ' . mysql_error());
$db = mysql_select_db('XX',$connection) or die('No pudo seleccionarse la BD.');
$query='SELECT id,domain,path,last_updated,display_name
FROM wp_users
LEFT JOIN wp_blogs ON blog_id = id
WHERE is_public="yes" ORDER BY last_updated DESC';
$limit_results ? $query.=' LIMIT '.$limit_results : '';
$result=mysql_query($query);
//if (mysql_num_rows($result)>0)
//$i=0;
while ($row = mysql_fetch_array($result))
{
$table[$i]['path']=$row['path'];
$table[$i]['domain']=$row['domain'];
$table[$i]['name']=$row['display_name'];
$table[$i]['id']=$row['id'];
/* hack for blogname */
$subquery='SELECT option_value FROM wp_'.$table[$i]['id'].'_options WHERE option_id="2"';
$subresult=mysql_query($subquery);
if (mysql_num_rows($subresult)>0) {
$table[$i]['blogname']=mysql_fetch_array($subresult);
$table[$i]['blogname']=$table[$i]['blogname'][0];
if (!$table[$i]['blogname']) $table[$i]['blogname']='untitled';
}
/* end of hack for blogname*/
$subquery='SELECT comment_id,comment_date,comment_author,post_date,post_title,post_name
FROM wp_'.$row['id'].'_comments
LEFT JOIN wp_'.$row['id'].'_posts ON id=comment_post_ID
ORDER BY comment_date DESC
LIMIT 1';
$subresult=mysql_query($subquery);
if (mysql_num_rows($subresult)>0)
{
$temp=mysql_fetch_row($subresult);
$table[$i]['comment']=true;
$table[$i]['comment_date']=$temp['1'];
$table[$i]['comment_author']=$temp['2'];
$table[$i]['comment_post_path']=explode(' ',$temp['3']);
$table[$i]['comment_post_path']=str_replace('-','/',$table[$i]['comment_post_path'][0]);
$table[$i]['comment_post_title']=$temp['4'];
$table[$i]['comment_post_name']=$temp['5'];
$table[$i]['comment_post_date']=$temp['3'];
$table[$i]['comment_post_url']='http://'.$table[$i]['domain'].$table[$i]['path'].$table[$i]['comment_post_path'].'/'.$table[$i]['comment_post_name'].'#comments';
unset($temp);
}
$subquery='SELECT id,post_date_gmt,post_date,post_title,post_name, post_content
FROM wp_'.$row['id'].'_posts
WHERE post_status=\'publish\'
ORDER BY post_date_gmt DESC
LIMIT 1';
$subresult=mysql_query($subquery);
if (mysql_num_rows($subresult)>0)
{
$temp=mysql_fetch_row($subresult);
$table[$i]['post']=true;
$table[$i]['post_except']=substr($temp[5],0,26).'...';
$table[$i]['post_path']=explode(' ',$temp['1']);
$table[$i]['post_path']=str_replace('-','/',$table[$i]['post_path'][0]);
$table[$i]['post_title']=$temp['3'];
$table[$i]['post_name']=$temp['4'];
$table[$i]['post_date']=$temp['2'];
$table[$i]['post_url']='http://'.$table[$i]['domain'].$table[$i]['path'].$table[$i]['post_path'].'/'.$table[$i]['post_name'];
unset($temp);
}
$subquery='SELECT count(comment_id) FROM wp_'.$row['id'].'_comments';
$subresult=mysql_query($subquery);
if (mysql_num_rows($subresult)>0)
{
$temp=mysql_fetch_row($subresult);
$table[$i]['comments_count']=$temp[0];
} else
{
$table[$i]['comments_count']=0;
}
$subquery='SELECT count(id) FROM wp_'.$row['id'].'_posts WHERE post_status="publish"';
$subresult=mysql_query($subquery);
if (mysql_num_rows($subresult)>0)
{
$temp=mysql_fetch_row($subresult);
$table[$i]['posts_count']=$temp[0];
} else
{
$table[$i]['posts_count']=0;
}
$i++;
}
echo "<table width=\"100%\" id=\"wmu_stats\">
";
echo "<tr><th>Blogauthor</th><th>Last Comment</th><th>Last Post</th><th>Psts</th><th>Cmmnts</th></tr>";
$i=0;
foreach ($table as $row)
{
$i++;
echo "<tr class=\"wmu_stats_row_". $i%2 ."\">";
echo "<td><b>".$row['name']."</b></td>";
echo "<td align=\"center\">";
echo $row['comment']==true ? "".$row['comment_author']."
<small>".$row['comment_date']."</small>" : '<b>—</b>';
echo "</td>";
echo "<td align=\"center\">";
if ($row['post']==true) {
echo "";
if ($row['post_title'])
echo $row['post_title'];
else
echo $row['post_except'];
echo "
<small>".$row['post_date']."</small>";
} else {
echo "<b>—</b>";
}
echo "</td>";
echo "<td><b>".$row['posts_count']."</b></td>";
echo "<td><b>".$row['comments_count']."</b></td>";
echo "</tr>";
}
echo "</table>";
?>
</div>