Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2003
    Albuquerque, NM

    Unanswered: error supression in PHP for Access queries

    We are using a non-DSN connection to Access (ADODB?).
    I'm pretty sketchy on the subject as I'm a MySQL fan myself, but oh well, it's a corporation, and I'm just a programmer.

    My problem comes when there is no data matching my SQL statement's criteria, instead of returning nothing, PHP spits out an error message. I don't want an error message from PHP, I'd rather write my own politely telling the administrators that "no data is available"... I do this for every other ODBC connection, but since we were not given a DSN for this particular database, I can't.

    I've but the @ everywhere, and used if($rs->$dbc->execute){} and if($rs->eof()){} and no matter what I do, the thing blows up right as it tries to execute it.

    Is there a way to keep it from reporting errors on a DSNless connection?

  2. #2
    Join Date
    Sep 2003
    You need to change some settings in your php.ini file. The main change is to set display_errors = off and log_errors = on. You can also specify where to log the errors and what level of error reporting you want.

    You then incorporate into your code something like this:
    if (!($result = mssql_query($query, $connection)))
    die("<h1>Error - could not execute query</h1>");

    All the user will see is the text between the H1 tags, but you will see a detailed message in your log file (specified in your php.ini).

    BTW, remember to change the query function above if you're not using MS SQL Server.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts