The main things I see that could be causing the query to fail are on these lines
PHP Code:
$query = 'select imageid, imagenm, imagedsc from portfolio';
if ($category != NULL ) {
$query = $query . 'where imagetp = ' . $category;
}
$query = $query . ' order by imagedtad';
You should be using capitals for the query SELECT WHERE, FROM and ORDER BY. Also it is best to put `backticks` around the table names and table columns (not single quotes, backticks are above the tab key). Then if $category is not an integer you need to put single quotes around it.
On this line
PHP Code:
$query = $query . 'where imagetp = ' . $category;
you need to add a space between the ' and where, like this
PHP Code:
$query = $query . ' where imagetp = ' . $category;
Otherwise when it is joined to the first part of the query it is reading it like this - from portfoliowhere imagetp = because you don't have the backticks.
I did notice that you misspelled the mysqli on this line, although that is not your real issue.
PHP Code:
if (mrsqli_connect_errno())
Then after this line
PHP Code:
$result = $db->query($query);
Put this
PHP Code:
echo mysqli_error();
I have never used mysqli so I don't know for sure that what I just said is 100% correct or it might be mysql_error().
Putting that line in will tell you if the query fails and why, then once the full code is perfected you can remove it for the live site.
Bookmarks