2015-07-15 11:59
浏览 43


I am trying to directly output HTML stored within my MySQL database as HTML, but the browser is rendering it as plain text.

I am working within OpenCart so I am not sure if there are references in other pages that may be affecting my code.

This is where I am defining the variable from the MySQL array

$results = $this->model_catalog_manufacturer->getManufacturers();
   foreach ($results as $result) {
      if (is_numeric(utf8_substr($result['name'], 0, 1))) {
            $key = '0 - 9';
        } else {
            $key = utf8_substr(utf8_strtoupper($result['name']), 0, 1);

        if (!isset($data['categories'][$key])) {
            $data['categories'][$key]['name'] = $key;

        $data['categories'][$key]['manufacturer'][] = array(
            'name' => $result['name'],
            'href' => $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $result['manufacturer_id']),
            'image' => $result['image'],
            'banner' => $result['banner'],
            'blurb' => $result['blurb'],

$data['brand_blurb'] = $manufacturer_info['blurb'];

This is where I am echoing the variable

<div class="brand_description"><?php echo $brand_blurb; ?></div>

Do you know what I might be doing wrong? I am still new to PHP so I appreciate the help.

Thank you

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • douchun6221 2015-07-15 12:04

    You declare $data['brand_blurb'] but you echo $brand_blurb. Change one of the two.
    so either:

    $brand_blurb = $manufacturer_info['blurb'];


    <div class="brand_description"><?php echo $data['brand_blurb']; ?></div>


    Maybe for some reason the characters are converted to Entity Numbers
    for example <h1>testing</h1> => &lt;h1&gt;testing&lt;&#47;h1&gt;

    Try the following, html_entity_decode()

    <div class="brand_description"><?php echo html_entity_decode($data['brand_blurb']); ?></div>
    解决 无用
    打赏 举报

相关推荐 更多相似问题