Review your favorite Linux distribution.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 04-29-2005, 04:03 PM   #1
Registered: Dec 2003
Location: Canada
Distribution: openSUSE Tumbleweed
Posts: 209

Rep: Reputation: 30
HTML not interpreted


i try to insert a text in a database (mysql)

in this text, there are php code i want to display... i use <code>...</code> to do this job

str = $_POST['texttutoriel'];
$str = preg_replace_callback('`&lt;(code|url|img)&gt;(.+?)&lt;/\1&gt;`si', 'bbcode', htmlentities($str));
$str = mysql_real_escape_string($str)

my bbcode function:

function bbcode($m) {
switch($m[1]) {
case 'code' :
return '<div class="code"><pre>'.$m[2].'</pre></div>';

you can see the result here:

the part where i use <code> </code>... is ok, you can see it... the rest of the text is not interpreted by the web navigator...

any idea

Old 04-29-2005, 05:00 PM   #2
Registered: Feb 2005
Location: Ottawa/Montréal
Distribution: Slackware + Darwin (MacOS X)
Posts: 468

Rep: Reputation: 30
Salut mec. Your problem is that the HTML is being replaced, look at the page source:
&lt;p&gt;Dans cet article, nous allons voir:&lt;/p&gt;

&lt;li&gt;Oublie de mot de passe&lt;/li&gt;
Your HTML entities break the HTML tags since you are telling the browser to print a "left angle bracket, li, right angle bracket" instead of giving it a real markup.

You need to make sure < and > are not replaced by HTML entities.

Last edited by michaelsanford; 04-29-2005 at 06:04 PM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Merge Of Html Files Into A Single Html (or Pdf) fiomba Linux - Software 6 06-20-2011 07:28 PM
Php is not getting interpreted? swatward Programming 1 07-31-2005 03:48 PM
how to convert text(html) back to html. d1l2w3 Linux - Software 4 04-08-2005 08:16 PM
Konqueror + file:/usr/share/doc/HTML/index.html jon_k Linux - Software 2 11-25-2003 05:06 AM
HTML Guru's or website Geeks (anyone who knows html) MasterC General 6 07-05-2002 01:59 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:10 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration