hello Everyone
I was wondering if anyone can help me with a little php and mysql problem occurred to the CMS i am using.
I have a function which is get data from a table after updating the table, the code is as follow:
public function getHtmlWrapper($id) {
//get entire html wrapper
$sql = "SELECT id, theme_name, html_wrapper FROM ".TABLE_PREFIX."themes WHERE id = $id";
$result_id = $this->db->query($sql);
$theme_data = $this->db->fetchToRow($result_id);
//read file in to database
$file_content = file_get_contents(SITE_ROOT.'/themes/'.$theme_data["theme_name"].'/index.php');
if($file_content) {
$this->db->update('themes',
array('html_wrapper'=>$file_content),
"id = '".(int) $id."'");
}
//get entire html wrapper
$sql = "SELECT id, theme_name, html_wrapper FROM ".TABLE_PREFIX."themes WHERE id = $id";
$result_id = $this->db->query($sql);
$theme_data = $this->db->fetchToRow($result_id);
return $theme_data;
}
the " $this->db->query
" is calling a update function in the database class which is: as follow:
function update($table, $data, $where='') {
$q="UPDATE ".TABLE_PREFIX."".$table." SET ";
foreach($data as $key=>$val) {
if(strtolower($val)=='null') $q.= "`$key` = NULL, ";
elseif(strtolower($val)=='now()') $q.= "`$key` = NOW(), ";
else $q.= "`$key`='".$this->escape($val)."', ";
}
$q = rtrim($q, ', ') . ' WHERE '.$where.';';
//echo $q;
return $this->query($q);
}
function escape($string) {
if(version_compare(phpversion(),"4.3.0")=="-1") {
return mysql_escape_string($string);
} else {
return mysql_real_escape_string($string);
}
}
when I do var_dump($file_content) before update statement it gives me the contents :
<? include "layout/header.php" ?>
<? $body = (isset($body))?$body:'home'?>
<? include 'contents/'.$body.'.php' ?>
<? include 'layout/footer.php' ?>
but once the table is updated, the "html_wrapper" field in the table has an extra ? before:
<? include "layout/header.php" ?>
<? $body = (isset($body))?$body:'home'?>
<? include 'contents/'.$body.'.php' ?>
<? include 'layout/footer.php' ?>
that makes the "html_wrapper" field has the value:
?<? include "layout/header.php" ?>
<? $body = (isset($body))?$body:'home'?>
<? include 'contents/'.$body.'.php' ?>
<? include 'layout/footer.php' ?>
I was wondering where the extra ? at the begining come from?
very much appreciated for any help and suggestions?
thank you