if (@move_uploaded_file($image['tmp_name'], "../uploads/{$randomFileName}")) { $img_path = $randomFileName; } } else { $img_path = ""; } if ($video) { $randomFileName = randomFileNameGenerator("Vid_") . "." . end(explode(".", $video['name'])); if (@move_uploaded_file($video['tmp_name'], "../uploads/{$randomFileName}")) { $vid_path = $randomFileName; } } else { $vid_path = ""; } $category_id = GeneralFunctions::getCategoryId($category); $category_question_id = GeneralFunctions::getCategoryQuestionId($title); $uid = GeneralFunctions::getUserId($token); if ($uid) { if ($video) { $sql = "Insert into question(id,user_id,category_id,category_question_id,answer,image,video,type,created_on) values(DEFAULT,:uid,:category_id,:category_question_id,:answer,:image,:video,'video',NOW())"; } else { $sql = "Insert into question(id,user_id,category_id,category_question_id,answer,image,video,type,created_on) values(DEFAULT,:uid,:category_id,:category_question_id,:answer,:image,'','image',NOW())"; } $sth = $conn->prepare($sql); $sth->bindValue('uid', $uid); $sth->bindValue('category_question_id', $category_question_id); $sth->bindValue('image', $img_path); $sth->bindValue('answer', $answer); $sth->bindValue('category_id', $category_id); if ($video) { $sth->bindValue('video', $vid_path);