请参阅此答案以查看主要问题。
您如何解决准备好的语句中的以下错误消息?
我有一个 index.php,我通过许多处理程序将数据放入其中。以下错误消息出现在以下 URL 中,该 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']));
我根据 Daniel 的建议将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']));
我仍然收到相同的错误消息。