3 ms·
One reason you might actually want to silence a warning. You might be developing an application that functions in some P2P type fashion or is specifically inte
by jiggy2011 14y ago
One reason you might actually want to silence a warning.
You might be developing an application that functions in some P2P type fashion or is specifically intended to be used in situations where network access will be intermittent (on a boat perhaps?).
In such a case a mysql_connect call may have a high chance of failing and your application is designed in such a way as to assume that this is likely (i.e working with the return code).
In such a case failing the connection is not an error but expected behaviour.
- jmathai 14y agoProblem is when you suppress the error to handle failed connections but didn't anticipate other errors which go unnoticed and make tracking bugs VERY difficult.
- pekk 14y agoThis flags a design flaw, perhaps in mysql_connect. If a warning is trivial enough that it's reasonable to silence, it shouldn't exist. Otherwise, it's not reasonable to silence it! I find it hard to believe that this is actually considered acceptable.
- jiggy2011 14y agoSurely that depends on your application, in 99.9% of cases where you are using LAMP to host some site a failed mysql_connect is probably an epic fail condition. My point is rather that there may certainly be applications where this is not the case. This is an area where exceptions are better than dumb warnings.
- jtreminio 14y agoDon't use mysql_*. Says so right in the docs. PDO can be used with try/catch.
- justinator 14y agoEpic? http://semi-rad.com/2013/01/everything-is-epic/ http://semi-rad.com/2013/01/everything-is-epic/
- astrodust 14y agoUsing mysql_query is an epic fail condition. Period.