I am tring to create a page that allows me to dynamically build new web pages. To do that, I have to dynamically put a line of code into Mysql.
This is the line I want to be put in the database:
<?php $_SESSION[id]=$user_id; $pagename='$newpage'; ?>
where $user_id and $newpage variables has previously been defined and their value must be put in hard code (i.e. if $user_id is 13 and $newpage is 'index" the line in the database would look like:
<?php $_SESSION[id]=13; $pagename='index'; ?>
However, when I try to run the following code, I get all kinds of errors, such as:
"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 'index';' WHERE `template_name` = 'temp'' at line 1"
Here is the code I have written, any ideas would be appreciated on how to fix it:
Code: Select all
<?PHP
include "g/global/database.php";
$user_id=13;
$newpage='index';
$temp_text="<?php $_SESSION[id]=$user_id; $pagename='$newpage';?>";
$queryString = "UPDATE template_wim SET template_header = '$temp_text' WHERE `template_name` = 'temp'";
mysql_query($queryString) or die(mysql_error());
?>