PHPでのデータベース更新でセミコロンを使ってbindParamした方法で更新できないです。
更新できない方のコードに何か問題ありますでしょうか?
更新はできていませんが、resultの結果は真になります。
更新できるコード
PHP
1 $sth = $dbh->prepare("UPDATE test_tbl SET test = '$test', test1 = '$test1', test2= '$test2', test3= '$test3' WHERE id = '$id'"); 2 $result = $sth->execute(); 3
更新できないコード
PHP
1 $sth = $dbh->prepare("UPDATE test_tbl SET test = ':test', test1 = ':test1', test2 = ':test2', test3 = ':test3' WHERE id = ':id'"); 2 $sth->bindParam(':test', $test, PDO::PARAM_INT); 3 $sth->bindParam(':test1', $test1, PDO::PARAM_STR); 4 $sth->bindParam(':test2', $test2, PDO::PARAM_STR); 5 $sth->bindParam(':test3', $test3, PDO::PARAM_STR); 6 $sth->bindParam(':id', $id, PDO::PARAM_STR); 7 $result = $sth->execute();
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/03/08 02:23