Welcome Guest, Not a member yet? Register   Sign In
codeigniter issues with DB and special characters
#1

Hi guys

i am using an app in php which was designed and using codeigniter 1.7.xx version i think

i have an issue regarding charset and i am kind of lots perhaps someone might help me

i am tryint to find for URLencode and decode functions on codeigniter.


i have an issue regarding the following plaintext which gets stored on my mysql db as special character.


so first things first


on codeignite i have setup my db  charset on  UTF-8



config.php
$config['charset'] = "UTF-8";




database.php
$db['default']['char_set'] = "utf8";

$db['default']['dbcollat'] = "utf8_general_ci";



also i have tried db  with latin1 and latin1_general_ci


and on mysql db in have all sql db now changed to utf8_genral_ci  and i have also tested in in latin1

my problem is the following

i have a config webgui page in php

which collects the input data for a autoconfiguration file it gets generated..

this autoconfiguration options is an option which selects specific data unique from each device tunner

so this is my config example


Auto_ipv4 = 239.106.%card.%number


this %card and %number are data input from specific hardware unique data..


on my device console it works great..


but on the webgui php when i press write to store this on the database it gets stored as  239.106.?rd.%number

because it classifies this %ca  as special character ?


so how can i changet this in order to make it interpreter as a simple text input data to store it on my mysql db ?


is there a solution for this? i am kind of lost any help would be appreciated..


i have the folloowing code on /controllers

config.php

PHP Code:
<?php
/**
 
 */

class Config extends Controller {
 
   public function __construct() {
 
       parent::Controller();
 
       $this->load->model('config_model');
 
       $this->load->helper('form');
 
       $this->load->library('form_validation');
 
       $this->load->helper('url');
 
       $this->load->database();
 
   }

 
   public function index($status=''$type='') {
 
       $data['all'] = $this->config_model->findAll();
 
       if ($status != ''$data['user_msg']['status'] = $status;
 
       if ($type != ''$data['user_msg']['type'] = $type;
 
       
        $this
->load->view('header');
 
       $this->load->view('navigation');
 
       $this->load->view('config/index'$data);
 
       $this->load->view('footer');
 
   }
 
   
    
    
public function edit($id$status='') {
        if (
$status == '' OR $status == 'error') {
            
$data['config'] = $this->config_model->find($id);
            
$this->load->view('header');
 
           $this->load->view('navigation');            
            
$this->load->view('config/edit'$data);
            
$this->load->view('footer');
        }
        elseif (
$status == 'valid') {
            
$this->setValidation();
     
       if ($this->form_validation->run() == true) {
     
           $data['value'] = $this->input->post('value'true);
 
   
                $this
->config_model->update($id$data);
     
           redirect('config/index/success/form');
     
       }
     
       else {
     
           redirect('config/edit/'.$id.'/error');
     
       }
        }
 
   }
 
   
    public 
function setValidation() {
 
       $this->form_validation->set_rules('value''Valeur''required');
 
   }







This is the export.php code

PHP Code:
<?php
/**
 
 */

class EXPORT extends Controller {
 
   public function __construct() {
 
       parent::Controller();
 
       $this->load->model('config_model');
 
       $this->load->model('tuner_model');
 
       $this->load->model('chaine_model');
 
       $this->load->helper('form');
 
       $this->load->library('form_validation');
 
       $this->load->helper('url');
 
       $this->load->database();
 
   }

 
   public function index($status=''$type='') {
 
       $data['config'] = $this->config_model->findAll();
 
       $data['transponder'] = $this->tuner_model->findByIsActive();
 
       $data['chaine'] = $this->chaine_model->findAll();
 
       $this->load->view('header');
 
       $this->load->view('navigation');
 
       $this->load->view('export/index'$data);
 
       $this->load->view('footer');
 
   }
 
   
    public 
function send() {
 
       exec('sudo /etc/init.d/portalnetheadend2 stop');
 
       $path '/etc/portalnetheadendconfig';
 
       $opath opendir($path);
 
       while ($f readdir($opath)) {
 
           if (substr($f, -5) == '.conf') {
 
               unlink($path.'/'.$f);
 
           }
 
       }
 
       
        
for ($i=1$i <= $this->input->post('nb_file'true); $i++) {
 
           //echo $this->input->post('nb_file', true);
 
           //echo $this->input->post('exportfile-'.$i, true);
 
           //echo $this->input->post("export-2", true);
 
           $handle fopen($path.'/'.$this->input->post('exportfile-'.$itrue), 'w');
     
       fwrite($handle$this->input->post('export-'.$itrue));
     
       fclose($handle);
 
       }
 
       exec('sudo /etc/init.d/portalnetheadend2 start');
 
       $this->load->view('header');
 
       $this->load->view('navigation');
 
       $this->load->view('export/send');
 
       $this->load->view('footer');
 
   }

And this is the view and edit php files
PHP Code:
<?php if (isset($user_msg['status'])): ?>

    <div class="flashbox <?=$user_msg['status']?>">
        <?php if ($user_msg['status'] == 'success' && $user_msg['type'] == 'form') echo "Os parametros de configuração foram alterados com sucesso.";?>
        <?php if ($user_msg['status'] == 'error' && $user_msg['type'] == 'form') echo "Não foi possivel modificar os parametros de configuração.";?>
    </div>
<?php endif; ?>

    <br/>
    <?=form_open('config/edit/'.$config->id.'/valid')?>
    <table class="form">
        <tr>
            <th>Configurar parametros</th>
            <td><?=$config->name?></td>
            <td><input type="text" name="value" value="<?=$config->value?>" /></td>
        </tr>
        
        <tr>
            <td colspan="2"><input type="submit" value="Gravar"/></td>
        </tr>
    </table>
    <?=form_close()?>

PHP Code:
<?php if (isset($user_msg['status'])): ?>
    <div class="flashbox <?=$user_msg['status']?>">
        <?php if ($user_msg['status'] == 'success' && $user_msg['type'] == 'form') echo "Os parametros de configuração foram alterados com sucesso.";?>
        <?php if ($user_msg['status'] == 'error' && $user_msg['type'] == 'form') echo "Não foi possivel alterar os parametros de configuração.";?>
    </div>
<?php endif; ?>

    <table class="table" cellspacing="0" accept-charset="UTF-8">
        <tr>
            <th>Parametros</th>
            <th>Valores</th>
            <th>Editar</th>
        </tr>
        <?php foreach($all as $item): ?>
        <tr>
            <td><?=$item->name?></td>
            <td><?=$item->value?></td>
            <td><a href="<?=site_url('config/edit/'.$item->id)?>"><img src="<?=base_url()?>/css/icon/pencil.png" title="Gravar"/></a></td>
        </tr>    
        <?php endforeach; ?>
    </table> 

Basically i just need to store this data without beeing fetched as special character  just as plain text.

any help will be appreciated 

Thxs
PortalNET
Reply


Messages In This Thread
codeigniter issues with DB and special characters - by PortalNET - 05-08-2018, 11:16 AM



Theme © iAndrew 2016 - Forum software by © MyBB