0

I Have a old database to maintain .... they have stored html tags in there database and was using old mysql with php to get outupt ... Now i am trying to use it through function and PDO to get output .... not getting output right .... its just giving html tags display insted of formatting the paragraph ... how can i fix it , here is my code --> Function

function movie_page($name,$date){
    global $host, $dbname, $user, $pass;
    $DBH = new PDO("mysql:host=$host;dbname=$dbname", $user, $pass);
    $STH = $DBH->prepare("SELECT * FROM bh_movies WHERE name = ? and re_date = ?");
    $STH->bindValue(1, "$name", PDO::PARAM_STR);
    $STH->bindValue(2, "$date", PDO::PARAM_STR);
    $STH->execute();
    $STH->setFetchMode(PDO::FETCH_ASSOC);
    return $STH;
    }

and output is

$STH = movie_page($id,$date);
     while (($row = $STH->fetch()) !== false) {
    if ($row['actors'] !=''){
    echo '<tr>
            <td><h1><a href="movie_page.php?id='.$row['name'].'">'.$row['name'].'</a></h1></td>
            <td>'.date('d-M-Y',$row['re_date']).'</td>
            <td><a href="movie_page.php?id='.$row['name'].'">
            <img src="'.$row['small_poster'].'" title="'.$row['name'].'" alt="'.$row['name'].'" height="97" width="182"/>
            </a>
            </td>
            <td><a href="movie_page.php?id='.$row['a'].'">
            <td>'.$row['actors'].'</td>
            <td>'.$row['small_desc'].'</td>
            <td>'.$row['big_desc'].'</td>
          </tr>';

     }

i am getting Html tags in output ... instead of format paragraph something like this

<font color="green"><B><u>Characters</u></B></font><br><br> <B>Sonu Dilli (KKC)</B> Emraan Hashmi<BR><BR> Sonu Dilli is a streetsmart 

please help

* INPUT Source *

function insert_data(){
    global $host, $dbname, $user, $pass;
    $DBH = new PDO("mysql:host=$host;dbname=$dbname", $user, $pass);
    $STH = $DBH->prepare("INSERT IGNORE INTO bh_movies 
    (name, bh_link, re_date,  small_poster, big_poster, small_desc, big_desc, actors) 
    value (:name, :bh_link, :re_date, :small_poster, :big_poster, :small_desc, :big_desc, :actors)");
    return $STH;
}
9
  • What format is the HTML in when it enters the database? Can you show the code that is used to enter the stuff? Commented Jun 24, 2012 at 13:49
  • @Pekka Same shown in example result ... Commented Jun 24, 2012 at 13:50
  • what do you see in the browser's "source code" view? Commented Jun 24, 2012 at 13:51
  • @Pekka its braking it down .... &lt;font color=&quot;green&quot;&gt;&lt;B&gt;&lt;u&gt;Characters&lt;/u&gt;&lt;/B&gt;&lt;/font&gt;&lt;br&gt;&lt;br&gt; &lt;B&gt;Sonu Dilli Commented Jun 24, 2012 at 13:53
  • 1
    Your data is being converted into HTML entities at some point. Either find the point where it is being converted (probably using htmlspecialchars()) or decode the data when it comes from the database (using htmlspecialchars_decode()) Commented Jun 24, 2012 at 14:03

2 Answers 2

5

Your data is being converted into HTML entities at some point. Either find the point where it is being converted (probably using htmlspecialchars()) or decode the data when it comes from the database (using htmlspecialchars_decode()).

Sign up to request clarification or add additional context in comments.

2 Comments

For example, if I formatted text as bold, the out put should show bold letters.
@CJ the same answer applies - find out where tags are converted into entities, and fix it there; or use the decode function
0

html_entity_decode() to decode the HTML from database.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.