You need to use pg_result_error or pg_last_error. Generally, you code to run the query, in the next line you check for an error and pass the error off to some error handling function

ie

$result = pg_query($sql);
if (pg_last_error($result) == false){  //here was an error
 $error = pg_last_error($result) ;
  handle_error ($error);
}//end if

continue with rest of page

hth

bastien


From: "Tumurbaatar S." <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Detailed db error codes
Date: Mon, 27 Sep 2004 18:35:00 +0800

I work with PHP5 and PostgreSQL7.4
Currently (for testing purpose) my script catches
the db errors and echoes them to a client without
any manipulation. But I need to examine these errors
and echo messages according the error type/class.
From the PostgreSQL doc:

...All messages emitted by the PostgreSQL server are assigned five-character
error codes that follow the SQL standard's conventions for "SQLSTATE" codes.
Applications that need to know which error condition has occurred should
usually test the error code, rather than looking at the textual error
message. The error codes are less likely to change across PostgreSQL
releases, and also are not subject to change due to localization of error
messages...


Anybody know how to get the PostgreSQL error code/class in PHP?

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


_________________________________________________________________
Scan and help eliminate destructive viruses from your inbound and outbound e-mail and attachments. http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines Start enjoying all the benefits of MSNŽ Premium right now and get the first two months FREE*.


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to