第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

向數(shù)據(jù)庫(kù)添加第四個(gè)參數(shù)后,通過(guò) Postman POST 數(shù)據(jù)時(shí)發(fā)生錯(cuò)誤

向數(shù)據(jù)庫(kù)添加第四個(gè)參數(shù)后,通過(guò) Postman POST 數(shù)據(jù)時(shí)發(fā)生錯(cuò)誤

PHP
手掌心 2021-11-05 15:20:24
我正在嘗試將新條目發(fā)布到數(shù)據(jù)庫(kù)中。當(dāng)有四個(gè)參數(shù)時(shí):id 標(biāo)題描述鏈接代碼工作正常。但是在我添加第五個(gè)“圖像”參數(shù)并嘗試通過(guò)郵遞員發(fā)布后,代碼返回:“添加條目時(shí)出錯(cuò)”。API 是用 PHP 編寫(xiě)的,通過(guò) mysqli 連接到數(shù)據(jù)庫(kù)。if(isset($_POST['title'])&&isset($_POST['description'])&&isset($_POST['link'])&&isset($_POST['image'])){$title = $_POST['title'];$description = $_POST['description'];$link = $_POST['link'];$image = $_POST['image'];$query = "INSERT INTO votes( title, description, link, image) VALUES (?,?,?,?)";if($stmt = $con->prepare($query)){    mysqli_stmt_bind_param($stmt,"sss",$title,$description,$link,$image);    $stmt->execute();    if($stmt->affected_rows == 1){        $response["success"] = 1;                   $response["message"] = "News Successfully Added";               }else{        //Some error while inserting        $response["success"] = 0;        $response["message"] = "Error while adding entry";    }                   }else{    $response["success"] = 0;    $response["message"] = mysqli_error($con);}}else{$response["success"] = 0;$response["message"] = "missing mandatory parameters";}echo json_encode($response);?>我不知道為什么在數(shù)據(jù)庫(kù)中添加一列后不起作用,但是當(dāng)沒(méi)有“圖像”列時(shí)它可以工作。
查看完整描述

1 回答

?
江戶(hù)川亂折騰

TA貢獻(xiàn)1851條經(jīng)驗(yàn) 獲得超5個(gè)贊

論點(diǎn)必須正確


i - 整數(shù) d - 雙精度 s - 字符串 b - BLOB


if(isset($_POST['title'])&&isset($_POST['description'])&&isset($_POST['link'])&&isset($_POST['image'])){

$title = $_POST['title'];

$description = $_POST['description'];

$link = $_POST['link'];

$image = $_POST['image'];


$query = "INSERT INTO votes( title, description, link, image) VALUES (?,?,?,?)";

if($stmt = $con->prepare($query)){

    mysqli_stmt_bind_param($stmt,"ssss",$title,$description,$link,$image);

    $stmt->execute();

    if($stmt->affected_rows == 1){

        $response["success"] = 1;           

        $response["message"] = "News Successfully Added";           


    }else{

        //Some error while inserting

        $response["success"] = 0;

        $response["message"] = "Error while adding entry";

    }                   

}else{

    $response["success"] = 0;

    $response["message"] = mysqli_error($con);

}}else{

$response["success"] = 0;

$response["message"] = "missing mandatory parameters";}echo json_encode($response);?>


查看完整回答
反對(duì) 回復(fù) 2021-11-05
  • 1 回答
  • 0 關(guān)注
  • 212 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)