-1

This is the console error i got mysql_real_escape_string(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead. this error i got in Datatable library file.Anybody knows what is the issue?

My controller

public function manageuser()
        { 
             $tmpl = array ( 'table_open'  => '<table id="big_table" border="1" cellpadding="2" cellspacing="1" class="mytable">' );
            $this->table->set_template($tmpl); 

            $this->table->set_heading('First Name','Last Name','Email');

             $this->load->view('moderator/manageuser');
        }
         public function datatable()
        {

             $this->datatables
            ->select("mro_id,mro_name,mctg_name,mctg_id")
            ->from('jil_mroproducts')
            ->join('jil_mrocategory', 'jil_mroproducts.mro_category=jil_mrocategory.mctg_id', 'INNER')
           ->edit_column('mro_name', '<a href="User/edit/$1">$2</a>', 'mro_id, mro_name');
            //->unset_column('mro_id');
             echo $this->datatables->generate();      
        }

My View

<html>
<head>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> 
<title>Subscriber management</title>
<meta http-equiv="content-type" content="text/html;charset=UTF-8">
<link rel="stylesheet" href="<?php echo base_url();?>assets/css/datatable.css" type="text/css" media="screen"/>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/ui-lightness/jquery-ui.css" type="text/css" media="screen"/>   
<script type="text/javascript" src="<?php echo base_url(); ?>assets/js/jquery.dataTables.min.js"></script>
</head>
<body>
<div class="wrapper">
<script type="text/javascript">
        $(document).ready(function() {
    var oTable = $('#big_table').dataTable( {
        "bProcessing": true,
        "bServerSide": true,
        "sAjaxSource": '<?php echo base_url(); ?>moderator/User/datatable',
                "bJQueryUI": true,
                "sPaginationType": "full_numbers",
                "iDisplayStart ":20,
                "oLanguage": {
            "sProcessing": "<img src='<?php echo base_url(); ?>assets/images/ajax-loader_dark.gif'>"
        },  
        "fnInitComplete": function() {
                //oTable.fnAdjustColumnSizing();
         },
                'fnServerData': function(sSource, aoData, fnCallback)
            {
              $.ajax
              ({
                'dataType': 'json',
                'type'    : 'POST',
                'url'     : sSource,
                'data'    : aoData,
                'success' : fnCallback
              });
            }
    } );
} );
</script>
<h1>Subscriber management</h1>
<?php echo $this->table->generate(); ?>
    </div>
</body>

</html>

i used this code for datatable.

http://www.ahmed-samy.com/php-codeigniter-full-featrued-jquery-datatables-part-2/
Angel
  • 614
  • 6
  • 24
  • i got solution .... i used this code $sSearch = $this->ci->db->escape_like_str($this->ci->input->post('sSearch')); – Angel Feb 25 '16 at 09:33

1 Answers1

1

The code uses mysql_real_escape_string() in library so it is deprecated.

  1. You have to remove mysql_real_escape_string() from the code and use your custom code.

  2. Otherwise you must use mysqli driver for codeigniter. Then you can use mysqli_real_escape_string().

CodeIgniter switching driver from mysql --> mysqli

Update: Added Angel's solution below.

$sSearch =$this->ci->db->escape_like_str($this->ci->input->post('sSearch'));
Community
  • 1
  • 1
safin chacko
  • 1,345
  • 1
  • 11
  • 18
  • 1
    i got solution .... i used this code $sSearch = $this->ci->db->escape_like_str($this->ci->input->post('sSearch')); – Angel Feb 25 '16 at 09:33