What is the right way to save php code in database
What is the right way to save (php, html, js and mysql) code开发者_Python百科 in database
D'oh! Are you sure you want to do that? How are you going to version that and work with that code from within an IDE?
However, if you're really inclined to, just keep it in whatever CLOB your DBMS supports.
As you didn't provide any other info:
$mycode = '<html>
<head>
<title><?php echo $title; ?></title>
</head>
<body>
...
</body>';
mysql_query("INSERT INTO table SET mycode = '".mysql_real_escape_string($mycode)."');
I seriously doubt you want to do this, though.
I found this as I was creating something for the enduser to access and alter some php code.
and simply include('foo.inc')
the field in a page.
This is indeed risky and even though it's in a secure area, I wouldn't normaly try, but he who pays the piper calls the tune.
I've been trying for a while and not getting far at all.
精彩评论