« MODX Parse Error » MODX encountered the following error while attempting to parse the requested resource: « Execution of a query to the database failed - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 » SQL > SELECT fullname FROM `DBxxxxxx`.`modx_user_attributes` WHERE `DBxxxxxx`.`modx_user_attributes`.id = Basic info REQUEST_URI : http://www.xxx.com/2014/test Resource : [104]test Current Snippet : AuthorTime Referer : http://www.xxx.com/manager/index.php?a=3&id=104&dir=DESC&sort=createdon User Agent : Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Firefox/31.0 IP : 41.xxx.xx.xx Benchmarks MySQL : 0.0127 s (8 Requests) PHP : 0.0692 s Total : 0.0819 s Memory : 2.1851615905762 mb Backtrace 1 DocumentParser->executeParser() index.php on line 144 2 DocumentParser->prepareResponse() manager/includes/document.parser.class.inc.php on line 1579 3 DocumentParser->parseDocumentSource() manager/includes/document.parser.class.inc.php on line 1666 4 DocumentParser->evalSnippets() manager/includes/document.parser.class.inc.php on line 1461 5 DocumentParser->_get_snip_result() manager/includes/document.parser.class.inc.php on line 1060 6 DocumentParser->evalSnippet() manager/includes/document.parser.class.inc.php on line 1147 7 eval() manager/includes/document.parser.class.inc.php on line 1009 8 DBAPI->query() manager/includes/document.parser.class.inc.php(1009) : eval()'d code on line 51
<?php
/* <?php /*
* Simple snippet to return Author and time a document was created.
* Original code borrowed from MetaTag snippet by Miels, converted to MODX
* by Shane Briggs.
* AuthorTime snippet v1.2 (May 2006) by OncleBen31 (based on the original version by Jason Tyler)
*
* Parameters :
* - dateFormat : format of the Date (see PHP documentation for syntax)
* - usedDate : Date field to use (ex: createon, editeon, pub_date, etc...)
* - tpl : Template for the output. Use [+Date+] and [+Author+] in the parameter string
* ex : "Posté par <strong>[+Author+]</strong> le [+Date+]"
*/
// #### Parameters
// format for the Date
if(!isset($dateFormat)) {
$dateFormat="%d-%b-%y %H:%M";
}
// Date field to use (ex: createon, editeon, pub_date, etc...)
if(!isset($usedDate)) {
$usedDate='createdon';
}
// Template for the output. Use [+Date+] and [+Author+] in the parameter string
if(!isset($tpl)){
$tpl = "By <strong>[+Author+]</strong> on [+Date+] ";
}
// ### Code
$Author = "";
$docInfo = $modx->getDocument($modx->documentIdentifier);
// *** AUTHOR,Time***
$authorid = $docInfo['createdby'];
// Ensure proper charset is used
if ($modx->config['etomite_charset']=='UTF-8') {
$createdon = utf8_encode(strftime($dateFormat, $docInfo[$usedDate]));
} else {
$createdon = strftime($dateFormat, $docInfo[$usedDate]);
}
$tbl = $modx->getFullTableName('user_attributes');
$query = "SELECT fullname FROM $tbl WHERE $tbl.id = $authorid";
$rs = $modx->dbQuery($query);
$limit = $modx->recordCount($rs);
if($limit==1) {
$resourceauthor = $etomite->fetchRow($rs);
$authorname = $resourceauthor['fullname'];
}
if (!$authorname == ""){
$output = str_replace("[+Author+]",$authorname,$tpl);
$output = str_replace("[+Date+]",$createdon,$output);
}
// *** RETURN RESULTS ***
return $output;
?>This question has been answered by Bruno17. See the first response.
$docInfo = $modx->getDocument($modx->documentIdentifier,'*','all');