You are here: Inserting PHP5 and HTML code into MySQL « All PHP « IT news, forums, messages
Inserting PHP5 and HTML code into MySQL

Posted by Skylinux on 10/30/05 18:45

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация