0

Hello,

I am getting the following error message:

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/mochas/domains/zoink.sx33.net/public_html/includes/blogpost.php on line 54

My code (Line 54):

while($row = mysql_fetch_assoc($query))
2
Contributors
6
Replies
7
Views
4 Years
Discussion Span
Last Post by paulmcdoodles
0

@paulmcdoodles

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/mochas/domains/zoink.sx33.net/public_html/includes/blogpost.php on line 54

You know it would be nice to actually see the whole code instead of 1 line of code.

So you are having an error on here:

while($row = mysql_fetch_assoc($query))

The error means your $query is not connected to the DB or not selecting any data.

Edited by LastMitch: grammer

0

@LastMitch

Here is the FULL code:

<?php

class BlogPost
{

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

function __construct($inId=null, $inTitle=null, $inPost=null, $inPostFull=null, $inAuthorId=null, $inDatePosted=null, $signature = null)
{
    if (!empty($inId))
    {
        $this->id = $inId;
    }
    if (!empty($signature))
    {
        $this->signature = stripslashes($signature);
    }
    if (!empty($inTitle))
    {
        $this->title = $inTitle;
    }
    if (!empty($inPost))
    {
        $this->post = str_replace("<br><br>", "<br>", stripslashes($inPost));
    }

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

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

    $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;
}

}
?>
0

@paulmcdoodles

Did you write this code?

You should understand that you are using OOP? Did you know that?

$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);

Are you connected to the Database?

You need to fixed the query into for it to work.

0

Can you tell me how to fix it, or fix it for me, I'm not really good with PHP. Thanks, much appreciated!

0

@paulmcdoodles

Can you tell me how to fix it, or fix it for me, I'm not really good with PHP. Thanks, much appreciated!

No, I'm not gonna fixed for you. If you're not familiar with PHP then my advice is to learn it.

Here is a link you can learn about MYSQL

http://www.w3schools.com/sql/default.asp

0

Nevermind then, I don't know how to fix it and simply don't have time to learn PHP.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.