LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 04-29-2005, 04:03 PM   #1
os2
Member
 
Registered: Dec 2003
Location: Canada
Distribution: Suse 10
Posts: 206

Rep: Reputation: 30
HTML not interpreted


hi

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>';
break;
//...
}
}


you can see the result here: http://www.laboiteaprog.com/tutoriel60-2

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

thanks
 
Old 04-29-2005, 05:00 PM   #2
michaelsanford
Member
 
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:
Code:
&lt;p&gt;Dans cet article, nous allons voir:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Inscription&lt;/li&gt;
&lt;li&gt;Authentification&lt;/li&gt;

&lt;li&gt;Oublie de mot de passe&lt;/li&gt;
&lt;li&gt;D&eacute;connection&lt;/li&gt;
&lt;/ul&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.
 
  


Reply


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


All times are GMT -5. The time now is 05:55 AM.

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