I am attempting to build a snippet which will display a custom page title for my portfolio. The issue that I am having is my code only returns the 'else', yet when I run the query in MySql I am getting the name.
What am I doing wrong?
<?php
// Show All Errors
error_reporting(E_ALL);
ini_set('display_errors', '1');
$getID = $modx->quote($getID);
$ret = '';
$qry = "SELECT `name` FROM `modx_gallery_items` WHERE REPLACE(LOWER(`name`), ' ', '-') = $getID;";
$result = $modx->query($qry);
if ($result) {
$row = $result->fetch(PDO::FETCH_ASSOC);
if($row){
$ret = 'o7th Web Design » Portfolio » ' . $row['name'];
}else{ //It's showing this one on the page, yet the same query in MySQL returns `name`
$ret = 'o7th Web Design » Portfolio » Our Portfolio' . $qry;
}
unset($row);
}else{
$ret = 'o7th Web Design » Portfolio » Our Portfolio' . $qry;
}
// Return everything
echo $ret;
?>
var_dump($result)? If its returning 0 or FALSE, then your getting the last else, which is a duplicate of the else you commented. - phpisuber01object(PDOStatement)#26 (1) { ["queryString"]=> string(109) "SELECTname` FROMmodx_gallery_itemsWHERE REPLACE(LOWER(name), ' ', '-') = 'accu-time-systems';" }` - Kevin