inserting html into mysql
Posted: Mon Aug 18, 2003 10:49 pm
I am creating my own news management system. I want to be able to add a news story to a database and then get the news page to be dynamically generated. Is this insane? Below is a summary.
I am trying to create a page where I can insert a new record into a table. The table has 2 fields, id and news. I have a submission page (news_add.html) that has the form action for news_add.php. I cannot get the news in my form page into my db (it contains HTML code). I can get it to work with simple text (if i just enter "test" into my form field, that gets inserted as "value="test">". SO, it would seem that everything is wired properly, but for some reason I cannot insert html code through the form, only in phpmyadmin. I am doing something wrong, how can I do it right? I will paste the code from the two pages below. Thank you very much.
--code from news_add.html--
--code from news_add.php--
I am trying to create a page where I can insert a new record into a table. The table has 2 fields, id and news. I have a submission page (news_add.html) that has the form action for news_add.php. I cannot get the news in my form page into my db (it contains HTML code). I can get it to work with simple text (if i just enter "test" into my form field, that gets inserted as "value="test">". SO, it would seem that everything is wired properly, but for some reason I cannot insert html code through the form, only in phpmyadmin. I am doing something wrong, how can I do it right? I will paste the code from the two pages below. Thank you very much.
--code from news_add.html--
Code: Select all
<form action="news_add.php" method="post">
<div align="center">
<table width="80%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="6%" valign="top">HTML</td>
<td width="94%"><textarea name="news" cols="100" rows="25" id="news"></textarea></td>
</tr>
</table>
<p><br>
<input type="Submit" value="Add News">
</p>
</div>
</form>Code: Select all
<?phpinclude("dbinfoSite.inc.php");
mysql_connect(mysql,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query = "INSERT INTO news VALUES ('','$news')";
mysql_query($query);
mysql_close(); ?>