Php 在下面的代码中,我应该在哪里使用转义函数?
我应该如何在下面的代码中使用转义函数Php 在下面的代码中,我应该在哪里使用转义函数?,php,codeigniter,Php,Codeigniter,我应该如何在下面的代码中使用转义函数 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( '
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);
}
对于任何post或get请求,请使用Codeigniter的本机 请参阅下面的代码
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'),
);
我建议您不要在第一个字母上使用大写字母,例如:“game”而不是“game”如果您使用Codeigniter,您的查询将自动转义,但在我的数据库中,“”被替换为<和>.。尝试使用urlencode()-稍后将在家中发布一个示例谢谢您考虑我。我找到了解决办法。只需使用htmlspecialchars\u decode()函数即可