Anthony,
I find it is useful to write code such that every outcome, however remote, is handled 
by your code:

$query = "INSERT INTO ... blah ";
// pconnect, select and query
if ($link_identifier = mysql_pconnect(DBSERVERHOST, DBUSERNAME, DBPASSWORD)) {
        if ( mysql_select_db(DBNAME, $link_identifier)) {
                // run the query
                $queryResultHandle = mysql_query($query, $link_identifier) or die( 
mysql_error() );
                $rows = mysql_affected_rows($link_identifier);
                // decide what to do with the results
                switch( $rows ) {
                        case 0:
                                echo"Count for rows inserted is zero. No data was 
changed.<br>\n";
                                break;
                        case 1:
                                // do something
                                break;
                        default:
                                echo"Process anomaly. Notify the webmaster.<br>\n";
                } // switch( $rows ) {
        }else{ // select
                echo mysql_error();
        }
}else{ //pconnect
        echo mysql_error();
}

The $rows handling will vary depending on the nature of your query:
mysql_num_rows()
mysql_affected_rows()


Kind Regards,

Richard Creech
[EMAIL PROTECTED]
250.744.3350 Pacific Time Canada
Dreamriver Software Powers the Net
http://www.dreamriver.com

                                                        }
Anthony wrote:  
Message-Id: <[EMAIL PROTECTED]>
Date: Fri, 17 May 2002 05:35:51 -0400
To: [EMAIL PROTECTED]
From: Anthony Rodriguez <[EMAIL PROTECTED]>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"; format=flowed
Subject: Query/Error

<snip>

What code can I add to the script to find out the error of the query?


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

Reply via email to