Please, see this answer to see the main problem.
How can you solve the following error message in prepared statement?
I have a index.php to which I put data through many handlers. The following error message occurs at the following URL that is a URL after a login form.
http://localhost/codes/index.php?ask_question&[email protected]&passhash_md5=202cb962ac59075b964b07152d234b70
This question is based on this thread. I get a similar error as 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.
in the code *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']));
I changed the *handle_login.php* by Daniel's pieces of advice to
$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']));
I still get the same error message.