내가 준비된 문에 문제가 여기 내 코드입니다 :mysqli 치명적인 오류 : 비 객체() 멤버 함수의 bind_param에 전화
function query_array($table, $data) {
foreach ($data as $column => $value) {
$columns[] = sprintf("`%s` = '%s'", $column, $this->db->real_escape_string($value));
}
$column_list = join(',', $columns);
// Prepare the statement
$stmt = $this->db->prepare("UPDATE `?` SET ?");
$stmt->bind_param('ss', $table, $column_list);
// Execute the statement
$stmt->execute();
// Save the affected rows
$affected = $stmt->affected_rows;
// Close the statement
$stmt->close();
// ...
}
$ this-> DB 객체를 반환
$ table = 'settings'; (문자열)
$의 경우 column_list : (문자열)
`title` = 'Socialsd',`captcha` = '0',`public` = '',`private` = '',`time` = '1',`perpage` = '10',`message` = '140',`mail` = '1',`inter` = '10000',`size` = '1048576',`format` = 'png,jpg,gif',`sizeMsg` = '1048576',`formatMsg` = 'png,jpg,gif,bmp',`censor` = '',`ad1` = '',`ad2` = ''
내가지고있어 오류는 다음 작업을 시도하기 때문에
는Fatal error: Uncaught exception 'ErrorException' with message 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?' at line 1' in C:\xampp\htdocs\new\includes\classes.php:256 Stack trace: #0 C:\xampp\htdocs\new\sources\admin.php(225): updateSettings->query_array('settings', Array) #1 C:\xampp\htdocs\new\index.php(42): PageMain() #2 {main} thrown in C:\xampp\htdocs\new\includes\classes.php on line 256
나는이 원인이 무엇인지 알아낼 수 없습니다 괜찮습니다.
$query = sprintf("UPDATE `%s` SET %s", $table, $column_list);
$result = $this->db->query($query);
도움이 되었습니까?
업데이트 1 : 이유가 다운 투표 된 이유를 알고 계십니까? 알고있는 것이 좋을 것입니다.
업데이트 2 : 마지막 바인드 ($ column_list)를 제거하고 $ column_list의 전체 출력을 넣으므로 기본적으로 테이블 이름 만 바인딩 했으므로 이제 다른 오류가 발생합니다.
Can't find file: '.\diary\@003f.frm' (errno: 22)
이제는 정말 혼란 스럽습니다.
가능한 [mysqli :: SQL 오류 준비] (http://stackoverflow.com/q/11559186/1409082). – Jocelyn
@Jocelyn 주석을 주셔서 감사합니다. 수동으로 테이블 이름을'settings'로 설정하더라도, 오류는 여전히 똑같습니다. –