Why isn’t the line of code deleted with the error disabled?

I am using PHP classes to connect to a database. I can not solve the problem - please help me with this.

I have a function:

function getCampus($cm_id) //returns campus name
{
    $this->query = "select cm_name from campus where cm_id = ".$cm_id.";";
    $rd = $this->executeQuery();
    @$data = $rd->fetch_assoc();
}

and when I delete @from @$data, it does not work. Please help me: explain what the alternative path will be. Thank.

+3
source share
4 answers

@ is used to suppress errors and warnings.

@ is not your problem

+2
source

@- operator of the error suppressor. Using it to prefix a line of code suppresses all non-fatal errors. It’s a bad idea to use it almost every time.

, error_reporting(E_ALL) display_errors = On php.ini ( ini_set('display_errors', 'on')).

+6

@ , .

, @, . , $rd->fetch_assoc(). , .

+2

@, PHP, . , " ", $rd->fetch_assoc() .

+2

All Articles