Page 1 of 1

the @ character

Posted: Fri Mar 12, 2004 3:06 am
by malcolmboston
ive searched for this in the manual after seeing a script using this last night

Code: Select all

@mysql_query
i havent got a clue what it is for, am just wondering as the manual doesnt say

Thanks

Posted: Fri Mar 12, 2004 3:13 am
by JayBird
It supresses error messages
This will supress the injection of error messages into the data stream output to the web client. You might do this, for example, to supress the display of error messages were foo() a database function and the database server was down. However, you're probably better off using php configuration directives or error handling functions than using this feature.
See the section on error handling functions.

Mark

Posted: Fri Mar 12, 2004 3:19 am
by malcolmboston
ok but on my dbhandler.php (included in every page) page i have

Code: Select all

error_reporting(0)
does this negate the need for @ or does it stop different sorts of error messages?

Thanks as usual bech

Posted: Fri Mar 12, 2004 5:41 am
by m3mn0n
@ is good for running a function within an if statement so you can get your own custom error sequence. That's the way I mainly use it.

ex.

Code: Select all

<?php
if (@mysql_query($q))
{
  // do whatever
} else {
  // alert admin via email, insert count into textfile, etc, etc..
}
?>
So to answer your question, in a more direct way, no. The script has that for a reason and to remove it would undermind that reason. :) I'd just keep it there.