2012-06-15, 03:28 PM
I've been trying to do a template system for a site and so far all pages except for 1 are working. The query it is attempting to run is
This works fine in PHPMyAdmin, but when it runs it on a site it gets an error somehow.
This is generated from the following code:
The fact that the variable $templatelist starts with a comma is irrelevant because this is a global file and the file that is including it has the variable ending in a template name instead of a comma.
Any help?
SELECT * FROM `templates` WHERE `name` IN ('forumdisplay', 'threadlist', 'modoptions', 'forumjump', 'moderatorlist', 'doctype', 'header', 'header_log_in', 'navbar', 'logo', 'redirect', 'footer')
This works fine in PHPMyAdmin, but when it runs it on a site it gets an error somehow.
This is generated from the following code:
$templatelist .= ",doctype,header,header_log_in,navbar,logo,redirect,footer";
$explodedtemplates = explode(",", $templatelist);
$finish = count($explodedtemplates);
$start = 0;
$comma = ", ";
foreach($explodedtemplates as $template)
{
$where .= "'" . $template . "'";
++$start;
if ($start==$finish)
{
$comma = "";
}
$where .= $comma;
}
$where = preg_replace("/\A(.*?)([,])\Z/is", "$1", $where);
$query = "SELECT * FROM `templates` WHERE `name` IN ({$where})";
$query = $db->query($query);
The fact that the variable $templatelist starts with a comma is irrelevant because this is a global file and the file that is including it has the variable ending in a template name instead of a comma.
Any help?