0

この回答を参照して、主な問題を確認してください。


準備されたステートメントの次のエラー メッセージをどのように解決できますか?

多くのハンドラーを介してデータを配置する index.php があります。ログインフォーム後のURLである以下のURLで、以下のエラーメッセージが発生します。

http://localhost/codes/index.php?ask_question&email=masi.masi@gmail.com&passhash_md5=202cb962ac59075b964b07152d234b70

この質問は、このスレッドに基づいています。Daniel と同様のエラーが表示されます。

Warning: pg_prepare() [function.pg-prepare]: Query failed: ERROR: prepared statement "query11" already exists in /var/www/codes/handlers/handle_login_status.php on line 6
Prepared statement failed.

コードhandle_login.phpで

$dbconn = pg_connect("host=localhost port=5432 dbname=masi user=masi password=123");
$result = pg_prepare($dbconn, "query11", "SELECT passhash_md5 FROM users
             WHERE email=$1;");
$passhash_md5 = pg_execute($dbconn, "query11", array($_POST['email']));

ダニエルのアドバイスでhandle_login.phpを次のように変更しました

 $dbconn = pg_connect("host=localhost port=5432 dbname=masi user=masi password=123");
 try{
     $result = pg_prepare($dbconn, "query11", "SELECT passhash_md5 FROM users
         WHERE email=$1;");
     if($result){
         $result->rayPrepared['query11'] = true;    // I changed $this to $result
     }else{
         throw new Exception('Prepared statement failed.');
     }
 }catch(Exception $e){
     echo $e->getMessage();
 }
 $passhash_md5 = pg_execute($dbconn, "query11", array($_POST['email']));

それでも同じエラー メッセージが表示されます。

4

1 に答える 1

1

独自の実装を準備していますか? 実際に例外をスローしますか?

これを試して

if(is_null($result)) {
 throw new Exception("No valid Result");
}  

編集:
最初のコメントで答えを得ました

"Any error in the prepare is available from pg_last_error()."

pg_ last _ エラー(申し訳ありませんが、下線は cursiv 形式を作成します)

于 2009-08-09T18:53:02.653 に答える