I have a fairly simple question I’m guessing. I have the following code at the beginning of my function, but it must not be correct because it causes the blank to turn blank. If I comment out the IF statement, everything runs fine.
What am I doing wrong?
Sorry, it’s probably very basic…
function get_entries($order = 'newest', $slug = null) {
$wheresql = '';
if (isset($slug)) {
$wheresql = 'WHERE entries.category_id = (SELECT categories.category_id FROM categories WHERE categories.category_slug = "'. $slug .'")'
}
Basically, I just want to do something if the user supplied a $slug variable, otherwise skip it.
Thanks.
You are missing a semicolon in the
$wheresql =line, causing a parse error.You need to turn on error reporting to see these errors:
error_reporting(E_ALL);in the head of the script will do the trick.