2014-04-16 49 views
0

如何在下面的代码中使用转义函数?我应该在下面的代码中使用转义函数?

public function Add_video() 
{ 
    $Game_type = $_POST['Game']; 
    $Video_type = $_POST['video_type']; 
    $Url  = $_POST['url']; 
    $Url  = mysql_escape_string($Url); // Video url 

    $Data  = array(
     'Game_type' => $Game_type, 
     'Video_type' => $Video_type, 
     'Video_url' => $Url 
    ); 

    $this->db->insert('videos', $Data); 
} 
+3

如果您正在使用笨你的查询会自动被转义 – Zabs

+0

但在我的数据库“<','>”被替换成了&lt和&GT .. – kishan

+0

尝试使用进行urlencode() - 将发布以后在家里 为例http://uk3.php.net/urlencode – Zabs

回答

1

任何职位或get请求,请不要使用笨的本地functions

看到下面的代码

public function Add_video() 
{ 
    $Game_type = $this->input->post('Game'); 
    $Video_type = $this->input->post('video_type'); 
    $Url  = $this->input->post('url'); 
    //$Url  = mysql_escape_string($Url); // Video url 

    $data  = array(
     'Game_type' => $Game_type, 
     'Video_type' => $Video_type, 
     'Video_url' => $Url 
    ); 

    $this->db->insert('videos', $data); 
} 

或简单地创建你的数组马上:

$data  = array(
      'Game_type' => $this->input->post('Game'), 
      'Video_type' => $this->input->post('video_type'), 
      'Video_url' => $this->input->post('url'), 
     ); 

我建议你不要在第一个字母上使用大写字母,例如:“游戏”而不是o F“游戏”

相关问题