File is not an image"; $upload_ok = 0; } else { //echo "File is an image - " . $check_img["mime"]; $upload_ok = 1; //Check if file already exists if(file_exists($target_file)) { echo "File is already uploaded!"; $upload_ok = 0; } else { //Check file size if($file_size > 500000) { echo "Please enter a file size between 5mb"; $upload_ok = 0; } else { //Allow certain file formats if($img_file_type != "jpg" && $img_file_type != "png" && $img_file_type != "jpeg" && $img_file_type != "gif") { echo "JPG, PNG, JPEG and GIF files are allowed"; $upload_ok = 0; } else { //Check if $upload_ok is set to 0 by an error if($upload_ok === 0) { echo "File has not been uploaded"; } else { if(move_uploaded_file($temp_file_name, $target_file)){ // sql語法存在變數中 // $db_query = "INSERT INTO expert (id, expert_id, personal_id, name, title, picture, major, tel, tel_count, chat_id, chat_count, video_call, video_count, onsite_call, onsite_count, creater, create_at) VALUE (`$id`, `$expert_id`, `$personal_id`, `$name`, `$title`, `$target_file`, `$major`, `$tel`, `$tel_count`, `$chat_id`, `$chat_count`, `$video_call`, `$video_count`, `$onsite_call`, `$onsite_count`, `$creater`, `$create_at`)"; $db_query = "INSERT INTO expert(expert_id, personal_id, name, title, picture, major, tel, tel_count, chat_id, chat_count, video_call, video_count, onsite_call, onsite_count, creater) VALUES ('$expert_id', '$personal_id', '$name', '$title', '$target_file', '$major', '$tel', '$tel_count', '$chat_id', '$chat_count', '$video_call', '$video_count', '$onsite_call', '$onsite_count', '$creater')"; // 用mysqli_query方法執行(sql語法)將結果存在變數中 $result = mysqli_query($link,$db_query); } } } } } } } $affected = mysqli_affected_rows($link); mysqli_close($link); if ($affected > 0) { echo ""; } elseif ($affected == 0) { echo ""; } else { echo "{$db_query} 語法執行失敗,錯誤訊息SSS: " . mysqli_error($link); } } ?>