下面的代碼導致我錯誤Undefined index: id
並導致整個代碼中的更大的錯誤SyntaxError: JSON.parse: unexpected character
任何想法,我出錯了?這似乎是一個愚蠢的問題,但我是新來的節目,有這麼多的東西就知道了,所以這是一個有點硬在開始:)未定義的索引,syntaxerror.json.parse
protected function handle_file_upload($uploaded_file, $name, $size, $type, $error,
$index = null, $content_range = null) {
$file = parent::handle_file_upload(
$uploaded_file, $name, $size, $type, $error, $index, $content_range
);
if (empty($file->error)) {
$con = mysqli_connect("localhost","root","","login");
$q1 = "SELECT MAX(id) FROM masinos";
$res = mysqli_query($con,$q1);
$row = mysqli_fetch_array($res);
$max_id = $row["id"];
$max_id_plus = $max_id + 1;
$sql = "INSERT INTO files (`carID`,`name`, `size`, `type`, `title`, `description`)
VALUES($max_id_plus,?, ?, ?, ?, ?)";
$query = $this->db->prepare($sql);
$query->bind_param(
'sisss',
$file->name,
$file->size,
$file->type,
$file->title,
$file->description
);
$query->execute();
$file->id = $this->db->insert_id;
}
return $file;
}
哪裏是JSON代碼? –