Board index   FAQ   Search  
Register  Login
Board index php forum :: Database mySQL & php coding

Insert Html content in mysql

Codes here !

Moderators: macek, egami, gesf

Insert Html content in mysql

Postby lvidya » Mon Aug 06, 2012 12:30 am

hai, how to insert html codes into database
lvidya
New php-forum User
New php-forum User
 
Posts: 37
Joined: Wed Jun 20, 2012 3:20 am

Re: Insert Html content in mysql

Postby Jeroen » Sun Aug 12, 2012 8:22 pm

mysql_query("INSERT INTO `blabla` SET `bla` = '".$escapedHtmlCode."'");
Jeroen
New php-forum User
New php-forum User
 
Posts: 40
Joined: Fri Aug 10, 2012 4:37 pm

Re: Insert Html content in mysql

Postby NigelRen » Sun Aug 12, 2012 11:36 pm

You don't need to do anything special about inserting html codes into a database as they simply consider the content as a list of characters.

So using something like ( copied and modified from http://www.w3schools.com/php/php_mysql_insert.asp )
Code: Select all
<?php
$con = mysql_connect("localhost","peter","abc123");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("my_db", $con);

mysql_query("INSERT INTO Persons (FirstName, LastName, Age, Signature)
VALUES ('Peter', 'Griffin',35,'<b>Pete</b>)");

mysql_close($con);
?>

Would put the Pete in bold if simply including the signature in the html.
NigelRen
php-forum Active User
php-forum Active User
 
Posts: 450
Joined: Fri Aug 05, 2011 9:53 am


Return to mySQL & php coding

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.