View unanswered posts | View active topics It is currently Sat Aug 13, 2022 9:14 pm



Reply to topic  [ 2 posts ] 
 inserting html into mysql 
Author Message
Junior Member

Joined: Sun Aug 17, 2003 10:45 pm
Posts: 1
Post 
I am trying to create a page where I can insert a new recod 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. 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--
<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>




<input type="Submit" value="Add News">
</p>
</div>
</form>

--code from news_add.php--
<?
include("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();
?>

_end pasting_


Sun Aug 17, 2003 10:54 pm
Report this post
Profile
Junior Member

Joined: Sat May 10, 2003 1:39 pm
Posts: 37
Post 
Either

Code:
$query = "INSERT INTO news VALUES (NULL,'$news')";

or

Code:
$query = "INSERT INTO news (news) VALUES ('$news')";


Don't try to put a value into the id field.

_________________
Barand


Tue Aug 19, 2003 12:44 pm
Report this post
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
© Copyright 2003-2008 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.