Foros del Web » Programación para mayores de 30 ;) » Bases de Datos General »

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result...

Estas en el tema de Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result... en el foro de Bases de Datos General en Foros del Web. Hola, hace poco empecé a hacer un blog… no se mucho de mysql pero por algún motivo me tira un problema y quisiera saber porque ...
  #1 (permalink)  
Antiguo 13/11/2009, 15:56
 
Fecha de Ingreso: marzo-2009
Mensajes: 5
Antigüedad: 15 años, 1 mes
Puntos: 0
Exclamación Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result...

Hola, hace poco empecé a hacer un blog… no se mucho de mysql pero por algún motivo me tira un problema y quisiera saber porque es…
El problema que me da es este:
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /www/zxq.net/y/o/j/yojuegoonline/htdocs/includes/includes.php on line 24

este es el archivo includes:
Código PHP:
<?php
include 'blogpost.php';

$connection mysql_connect('acatengoelhost''acalacuenta''ylapass') or die ("<p class='error'>Sorry, we were unable to connect to the database server.</p>");
$database "yojuegoonline_zxq_onlineblog";
mysql_select_db($database$connection) or die ("<p class='error'>Sorry, we were unable to connect to the database.</p>");

function 
GetBlogPosts($inId=null$inTagId =null)
{
    if (!empty(
$inId))
    {
        
$query mysql_query("SELECT * FROM blog_posts WHERE id = " $inId " ORDER BY id DESC");
    }
    else if (!empty(
$inTagId))
    {
        
$query mysql_query("SELECT blog_posts.* FROM blog_post_tags LEFT JOIN (blog_posts) ON (blog_post_tags.postID = blog_posts.id) WHERE blog_post_tags.tagID =" $tagID " ORDER BY blog_posts.id DESC");
    }
    else
    {
        
$query mysql_query("SELECT * FROM blog_posts ORDER BY id DESC");
    }

    
$postArray = array();
while (
$row mysql_fetch_assoc($query))
    {
        
$myPost = new BlogPost($row["id"], $row['title'], $row['post'], $row['postfull'], $row["author_id"], $row['date_posted']);
        
array_push($postArray$myPost);
    }
    return 
$postArray;
}
?>
y el archivo blogpost.php:
Código PHP:
<?php
class BlogPost
{

public 
$id;
public 
$title;
public 
$post;
public 
$author;
public 
$tags;
public 
$datePosted;

function 
__construct($inId=null$inTitle=null$inPost=null$inPostFull=null$inAuthorId=null$inDatePosted=null)
{
    if (!empty(
$inId))
    {
        
$this->id $inId;
    }
    if (!empty(
$inTitle))
    {
        
$this->title $inTitle;
    }
    if (!empty(
$inPost))
    {
        
$this->post $inPost;
    }

    if (!empty(
$inDatePosted))
    {
        
$splitDate explode("-"$inDatePosted);
        
$this->datePosted $splitDate[2] . "/" $splitDate[1] . "/" $splitDate[0];
    }

    if (!empty(
$inAuthorId))
    {
        
$query mysql_query("SELECT first_name, last_name FROM people WHERE id = " $inAuthorId);
        
$row mysql_fetch_assoc($query);
        
$this->author $row["first_name"] . " " $row["last_name"];
    }

    
$postTags "No Tags";
    if (!empty(
$inId))
    {
        
$query mysql_query("SELECT tags.* FROM blog_post_tags LEFT JOIN (tags) ON (blog_post_tags.tag_id = tags.id) WHERE blog_post_tags.blog_post_id = " $inId);
        
$tagArray = array();
        
$tagIDArray = array();
        while(
$row mysql_fetch_assoc($query))
        {
            
array_push($tagArray$row["name"]);
            
array_push($tagIDArray$row["id"]);
        }
        if (
sizeof($tagArray) > 0)
        {
            foreach (
$tagArray as $tag)
            {
                if (
$postTags == "No Tags")
                {
                    
$postTags $tag;
                }
                else
                {
                    
$postTags $postTags ", " $tag;
                }
            }
        }
    }
    
$this->tags $postTags;
}

}
?>
si alguien me ayuda se lo agradesco muuuuucho
  #2 (permalink)  
Antiguo 13/11/2009, 17:23
Avatar de gildus  
Fecha de Ingreso: agosto-2003
Mensajes: 1.495
Antigüedad: 20 años, 8 meses
Puntos: 105
Respuesta: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL resul

Holas, para ver el problema podrias aumentar una linea en la parte de tu codigo como :

Cita:
function GetBlogPosts($inId=null, $inTagId =null)
{
if (!empty($inId))
{
$query = mysql_query("SELECT * FROM blog_posts WHERE id = " . $inId . " ORDER BY id DESC");
}
else if (!empty($inTagId))
{
$query = mysql_query("SELECT blog_posts.* FROM blog_post_tags LEFT JOIN (blog_posts) ON (blog_post_tags.postID = blog_posts.id) WHERE blog_post_tags.tagID =" . $tagID . " ORDER BY blog_posts.id DESC");
}
else
{
$query = mysql_query("SELECT * FROM blog_posts ORDER BY id DESC");
}

if(!$query) die(mysql_error());

Y del error que te muestre nos avisas.

Saludos
Gildus
__________________
.: Gildus :.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta

SíEste tema le ha gustado a 1 personas




La zona horaria es GMT -6. Ahora son las 02:43.