我遇到了一个问题:每次在数据库中插入内容时,都会显示/
。我该如何删除?我认为问题在于模型中的escape_str
。我可以用什么来替换它?
查看
foreach($ciList as $row)
{
echo "<p><input type=checkbox name=cname[] value=".$row->affected_ci."/>".$row->affected_ci."</p>";
}
CONTROLLER
public function insert()
{
$this->load->model('some_model');
$name = $this->input->post('name');
$cname = $this->input->post('cname');
foreach($cname as $key=>$value)
{
$success = $this->some_model->insertPerson($name,$cname[$key]);
}
if($success == TRUE)
$this->insert_page(TRUE);
else
$this->insert_page(FALSE);
}
MODEL
public function insertPerson($name,$cname)
{
$escName = $this->db->escape_str($name);
$eciName = $this->db->escape_str($cname);
$queryStr = "INSERT INTO appwarehouse.ci_table(app_id,ci_name) VALUES ('$escName','$eciName')";
$query = $this->db->query($queryStr);
return $query;
}
答案 0 :(得分:0)
更改
echo "<p><input type=checkbox name=cname[] value=".$row->affected_ci."/>".$row->affected_ci."</p>";
到
echo "<p><input type=checkbox name=cname[] value='".$row->affected_ci."' />".$row->affected_ci."</p>";
答案 1 :(得分:0)
更改为
foreach($ciList as $row){
echo "<p><input type='checkbox' name='cname[]' value='".$row->affected_ci."'/>".$row->affected_ci."</p>";
}