Click here to Skip to main content
12,753,809 members (34,236 online)
Rate this:
Please Sign up or sign in to vote.
See more: PHP
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\Program Files\xampp\htdocs\ZA_Kamez\include.php on line 21

What does this error mean??

include 'blogpost.php';

$connection = mysql_connect('localhost', 'login_h', '1234') or die ("<p class='error'>Sorry, we were unable to connect to the database server.</p>");
$database = "articles";
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)
	$query = null;
	if (!empty($inId))
		$query = mysql_query("SELECT * FROM blog_posts WHERE id = " . $inId . " ORDER BY id DESC"); 
		$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_up']);
		array_push($postArray, $myPost);
	return $postArray;
Posted 11-Sep-12 7:41am
Wes Aday 11-Sep-12 12:44pm
The error means your query failed.
Zoltán Zörgő 11-Sep-12 13:09pm
And this is the "ZA_Kamez\include.php" script? The row number seems not to match. But be sure to find the code line mentioned in the error message and add a var_dump(???); before it - where ??? is the variable you passed to the function.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

It means, mysql_query() function is failing and returning a boolean(False). Make sure you have rights to access blog_posts table or check if it exists or not.
You can also test your query on phpmyadmin...
Hysen Ndregjoni 11-Sep-12 14:14pm
thanks I found the problem , the table was called posts and I've used "blog_posts"

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170217.1 | Last Updated 11 Sep 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100