Search code examples
phperror-suppression

Why won't a line of code work with error suppressor removed?


I am using PHP classes to connect to a data base. I am unable to solve a problem -- please help me out regarding 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 remove @ from @$data, it doesn't work. Please help me out: explain what it is what an alternative way would be. Thanks.


Solution

  • @ is used to suppress errors and warnings.

    the @ is not your problem