有人可以幫助我什麼錯我的查詢?當我執行它時,輸出顯示如下。codeigniter發生數據庫錯誤
Error Number: 1064
您的
SQL語法錯誤;檢查對應於你的MySQL服務器版本在1號線
INSERT INTO touristspot(TouristspotID, AccountID, CategoryID, Name, Description, street, city_area, city) Values(0, 111, ?, ?, ?, ?, ?, ?)
我的控制器使用附近的正確語法手冊:
public function manager_spotdetails(){
$data = array(
'CategoryID' => $this->input->post('category'),
'Name' => $this->input->post('spotname'),
'Description' => $this->input->post('desc'),
'street' => $this->input->post('street'),
'city_area' => $this->input->post('city_area'),
'city' => $this->input->post('city')
);
$this->load->model('managerm');
$data['cat'] = $this->managerm->category();
$this->managerm->createspots($data);
$this->load->view('manager_spotdetails', $data);
}
public function createTouristspot(){
$this->load->model('managerm');
$data['cat'] = $this->managerm->category();
$this->load->view('manager_spotdetails');
}
「,,,,,)??????
我的模型:
public function createspots($data){
$b = $_SESSION['accountid'];
$this->db->trans_start();
$spot_id= $this->db->insert_id();
$sql3= "INSERT INTO touristspot(TouristspotID, AccountID, CategoryID, Name, Description, street, city_area, city) Values($spot_id, $b, ?, ?, ?, ?, ?, ?)";
$this->db->query($sql3, $data);
$this->db->trans_complete();
return $this->db->insert_id();
}
public function category(){
$this->db->select('CategoryID');
$this->db->select('CategoryType');
$this->db->from('category');
$query= $this->db->get();
return $query->result();
}
}
我的看法:
<div class="form-group">
<span class="input-group-addon" id="basic-addon1">Category Type</span>
<select class="form-control" name="category">
<?php foreach($cat as $row) {?>
<option value="<?php echo $row->CategoryID?>"><?php echo $row->CategoryType?></option>
<?php }?>
</select>
謝謝! :)在SQL
$sql3= "INSERT INTO touristspot(`TouristspotID`, `AccountID`, `CategoryID`, `Name`, `Description`, `street`, `city_area`, `city`) Values('$spot_id','$b', '', '', '','', '', '')";
我無法保存我輸入到數據庫中的那一個 – Ruhinn
在應用程序的config文件夾中轉到'database.php'並轉到'db_debug',並將其設置爲''db_debug'=> true,'Find實際的問題和解決它... –