cappedbot
cappedbot

Reputation: 55

How to insert HTML, PHP content into database in CodeIgniter

I want to store my PHP returned HTML code into a MySQL database. I have manually inserted into database. But when I fetch that data from the database, it is showing an error and the PHP code is not decoding.

For example: $title has value but it shows $title.

The error:

My controller:

$url_data=$this->capcee_news->get_site_details($default_url);
$data['title']=$url_data['vchr_paper_name'];
$data['header']=$url_data['part1'];
$this->load->view('blank',$data);

My model:

public function get_site_details($url='')
{
    if(!empty($url)){
        $this->db->select('*');
        $this->db->from($this->tables['papers']);
        $this->db->join('tbl_template','tbl_news_paper.theme_id=tbl_template.pk_int_temp_id');
        $this->db->where('site_url',$url);
        $data=$this->db->get()->row_array();
        return $data;}
    return false;
}

My view:

echo $header;

Database content:

<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title><?=$title;?></title>
<meta name="description" content="">

Upvotes: 1

Views: 660

Answers (1)

Kareem Essawy
Kareem Essawy

Reputation: 615

can you use the actual php tags like

<?php echo $title; ?>

also can you please post more code samples ?

Upvotes: 3

Related Questions