我想查询一个新的 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
提交
取消