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

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

致命錯(cuò)誤:未捕獲的 PDOException:SQLSTATE[HY093]:

致命錯(cuò)誤:未捕獲的 PDOException:SQLSTATE[HY093]:

C#
慕田峪9158850 2021-11-05 16:07:56
我正在嘗試通過(guò) php 對(duì) postgresql 數(shù)據(jù)庫(kù)運(yùn)行更新查詢。當(dāng)我嘗試這樣做時(shí),出現(xiàn)錯(cuò)誤。我嘗試將其更改id = ?為id = :id但沒有用我的update功能://update a student    public function updateStudent(){      $query = 'UPDATE ' . $this->table . ' ( name, course) VALUES ( :name, :course) WHERE id = ? ;';      $stmt = $this->conn->prepare($query);      $this->id = htmlspecialchars(strip_tags($this->id));      $this->name = htmlspecialchars(strip_tags($this->name));      $this->course = htmlspecialchars(strip_tags($this->course));      $stmt->bindParam(':id', $this->id);      $stmt->bindParam(':name', $this->name);      $stmt->bindParam(':course', $this->course);      if($stmt->execute()){        return true;      }      //print error      printf("Error: %s.\n", $stmt->error);      return false;    }錯(cuò)誤: Fatal error: Uncaught PDOException: SQLSTATE[HY093]: Invalid parameter number: mixed named and positional parameters in...它說(shuō)錯(cuò)誤在第 58 行,這行內(nèi)容是: $stmt = $this->conn->prepare($query); 我的錯(cuò)誤在 58 行之上。更新:如果我使用id = :id而不是id = ?,我會(huì)收到以下錯(cuò)誤:Fatal error: Uncaught PDOException: SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "(" LINE 1: UPDATE students ( name, course) VALUES ( $1, $2) WHERE id = ... ^ in
查看完整描述

1 回答

?
慕村225694

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

你不能使用 :param 和 ? 使用 :id 而不是 ?


但是對(duì)于更新,您可以使用


    'UPDATE ' . $this->table . ' 

        set  name = :name, 

         course = :course 

      WHERE id = :id ;';





   public function updateStudent(){

      $query = 'UPDATE ' . $this->table . ' 

                  set  name = :name, 

                       course = :course 

                WHERE id = :id ;';

      $stmt = $this->conn->prepare($query);


      $this->id = htmlspecialchars(strip_tags($this->id));

      $this->name = htmlspecialchars(strip_tags($this->name));

      $this->course = htmlspecialchars(strip_tags($this->course));

      $stmt->bindParam(':id', $this->id);

      $stmt->bindParam(':name', $this->name);

      $stmt->bindParam(':course', $this->course);


      if($stmt->execute()){

        return true;

      }

      //print error

      printf("Error: %s.\n", $stmt->error);

      return false;

    }


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

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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