Insert Html content in mysql

Codes here !

Moderators: egami, macek, gesf

Post Reply
New php-forum User
New php-forum User
Posts: 37
Joined: Wed Jun 20, 2012 3:20 am

Mon Aug 06, 2012 12:30 am

hai, how to insert html codes into database

New php-forum User
New php-forum User
Posts: 40
Joined: Fri Aug 10, 2012 4:37 pm

Sun Aug 12, 2012 8:22 pm

mysql_query("INSERT INTO `blabla` SET `bla` = '".$escapedHtmlCode."'");

php-forum Fan User
php-forum Fan User
Posts: 622
Joined: Fri Aug 05, 2011 9:53 am

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 )

Code: Select all

$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>)");

Would put the Pete in bold if simply including the signature in the html.

Post Reply