我应该如何在以下代码中使用转义函数?
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);
}
答案 0 :(得分:1)
对于任何帖子或获取请求,请使用Codeigniter的原生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'),
);
我建议你不要在第一个字母上使用大写字母,例如:“游戏”而不是“游戏”