Quote from: neosquared on November 30, 2005, 09:22:13 AMQuote from: Guide on November 27, 2005, 12:23:56 PMAnother reason to do that is if you want to do custom error reporting, like so:
The @ isn't usually necessary, it's just used to tell mysql not to report any errors. It's used when you know there can be an error occuring, but you know that error isn't important for the rest of your code and you still want your code to run the rest of the way.Code Select<?php
$query = @mysql_query('SELECT * FROM table');
if ($query) {
echo 'query successful';
} else {
echo 'query unsuccessful';
}
// If you only want to output a message on failure, you could do something like this:
$query = @mysql_query('SELECT * FROM table') OR echo 'query unsuccessful';
?>
Naturally, you could always replace the echo with something else. (exit(), mysql_error(), etc.)
or die works too. I use or die(mysql_error())