我想查詢一個新的 sql 表,代碼運行但它沒有向數據庫中插入任何內容。我試著回讀 pdo 手冊,但不明白我錯了哪一部分。$query = "INSERT INTO 'easycomputing'('STID', 'NAME', 'TONG') VALUES (:STID, :NAME, :TONG)";$dns = " mysql:host=localhost;dbname=phan1";$username="root"; $password= "";// $password="";try{ //access the database $db = new PDO($dns, $username, $password); //execute the query $statement = $db->prepare($query); $statement->bindValue(':STID', 137, PDO::PARAM_INT); $statement->bindValue(':NAME', 'tenten', PDO::PARAM_STR); $statement->bindValue(':TONG', 5, PDO::PARAM_INT); //execute the query if( $statement->execute() ){ echo "record tranfer successfully"; }else{ echo "fail to execute the record"; }
添加回答
舉報
0/150
提交
取消