Inserting PHP5 and HTML code into MySQL



I'm trying to use my database to store a lot of the redundant PHP and
HTML code.
Is there a special function I can use to insert the code into SQL, when
I try it using the input of a <textarea> the insert fails.

Here is a sample of what I would like to insert into a MySQL database.
######### code sample start
<tbody>
<tr>
<td style="vertical-align: top;">
<table style="width: 100%; text-align: left;" border="0"
cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="vertical-align: top;">
<?PHP
//Modified to include options and different templates
$Sec_run = $_POST['Sec_run'];
$inc_dir = '/path/to/inc/';
include $inc_dir.'menu-projects.inc'; //Include Menu
###### code sample end


And here is an example of how I'm currently adding the <textarea> text
into the database. It can insert plain text but no code.

########## PHP code insert example
$db="nameofdb";
//make mysql connection
$conn = @mysql_connect("localhost","$db_un_admin","$db_admin") or
die("Could not connect to MySQL server");
//select specified database
$rs = @mysql_select_db("$db", $conn) or die("Could not select database");

$sql = "insert into $Cat_name(Cat_ID , Title , Article , User_ID ,
Visible) values(\"$Cat_ID\", \"$Title\", \"$Article\", \"$User_ID\",
\"$Visible\") ";
//echo("<br>SQL: " . $sql . "<br><br"); //Debug
$result = mysql_query( $sql,$conn) or die("Could not insert into table
$Cat_name"); //Run query;
###########3 PHP code end

Any ideas on how to get this done are very appreciated.

Skylinux
.



Relevant Pages

  • Re: Executing PHP files on remote web server
    ... We have a commercial web host servicing our external clients, but we don't want to move the entire app and database to the web host because a lot of the data is sensitive. ... By loading the non-sensitive data into the web host's MySQL tables, our external clients can see their reports on the web. ... our web host put a firewall on the MySQL database so we can't insert data into the remote tables directly from the PHP pages running on our own web server. ...
    (comp.lang.php)
  • Database Comparison?
    ... after using it that php is built more than anything to easily sit on ... talking to a mysql database and spitting out html to ... use these things better I've made a rudimentary gui designer and some ...
    (comp.lang.php)
  • Re: How to use SQL "LIMIT" keyword against an MDB file
    ... that it will work with an MSAccess MDB file. ... PHP Programmer Guy. ... Except you've just "solved" his issue with a database redesign. ... from MySQL to Access in the first place. ...
    (comp.lang.php)
  • Re: help me
    ... field automatically assign its self a value of the next auto inc number ... I have a mysql database and i have it displaying whats currently there ... using php, the problem is that I cannot insert into the database ...
    (comp.lang.php)
  • Re: Help: Dreamweaver Database Conncetion Problem (PHP/MySQL)
    ... You probably can't connect to MySQL from outside the server, ... > on remote machines. ... you can't use Dreamweaver (or any other remote database tool) for ... I can upload my PHP site but the problem is that I ...
    (alt.php)