At 12:04 PM +1000 6/15/01, M Felipe wrote:
>I need help on testing the database for errors. Basically im writing a perl
>script to operate my database. When i open the database, i need it to return
>an error code if successful. steps such as:

Try running:

        perldoc DBI

and reading the information on checking for errors.  You want to know
about the PrintError and RaiseError attributes.

>
>open database
>check for error (did database open?)
>if error print error message
>else print successful.
>close database
>
>
>use DBI
>$dbh = DBI->connect("DBI:mysql:dbname","user","password");

$dbh will be undef if an error occurred (if RaiseError isn't enabled).

>$sth = $dbh->prepare("SELECT username from MyTable");

$sth will be undef if an error occurred (again, if RaiseError isn't enabled).

>(error checking here)
>
>$sth->execute;
>$dbh->disconnect;
>
>Basically on the error checking part, if successful $errorcode = 0 or if
>there is error $errorCode = 1;
>
>
>
>Thank all,
>Marbeen  Felipe


-- 
Paul DuBois, [EMAIL PROTECTED]

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to