NYCPHP Meetup

NYPHP.org

[nycphp-talk] @include() affects all error_reporting !?!?

Jonathan Rury ruryj at vuser.vu.union.edu
Fri Jul 25 22:50:17 EDT 2003


Errors are your friend but there are often better ways to handle errors than
just allowing PHP to dump its error message to the end-user, which often is
confusing to the person unfamiliar with PHP.

For instance, opening a database connection like this:
  @ $db = mysql_connect($HOST, $MYSQL_USER_NAME, $MYSQL_USER_PASSWORD);
  if (!$db)      // error connecting to database
  {                             // inform user and provide solutions
       echo "Error: Could not connect to database.  Please try again later.
or contact help at blah.com;";
       exit;
  }
is much better than just saying
$db = mysql_connect($HOST, $MYSQL_USER_NAME, $MYSQL_USER_PASSWORD);
which will continue executing the script, and waste cycles, while dumping a
much less meaningful error message.

Good coding practice is not to ignore malformed input or errors BUT better
coding is to respond intelligently to errors, rather than just dumping error
messages.


> I recently installed GForge, and they use @ all over the place,
> particular in front of the database connection code. So if your
> database isn't working, you just get a blank html page. No errors, no
> error log, just... nothing. It's terribly irritating, and particularly
> bad coding form.
>
> Errors are your friend!
>
> -- 
> - Adam
>
> -----
> Adam Fields, Managing Partner, fields at surgam.net
> Surgam, Inc. is a technology consulting firm with strong background in
> delivering scalable and robust enterprise web and IT applications.
> http://www.adamfields.com
> _______________________________________________
> talk mailing list
> talk at lists.nyphp.org
> http://lists.nyphp.org/mailman/listinfo/talk




More information about the talk mailing list