Hi, I've tried a few attempts to throw and catch an exception by executing the following query. I'm running it through my web browser and wiht the code above, it tells me that the exception (T_THROWS) is unexpected.

I've also tried to embed the SQL code in a try block and catch the exception of an invalid category name, and use an if(!catName) statement - to test if it's not been found, but the parser doesn't appear to like these ideas either, reporting the relevant "T_IF" and "T_TRY" errors.

I can't seem to find any help from general exception handling with php, so can you give me some advice?

public function selectCat($catName)
{
$wir3d = mysql_connect("mysqlhost.bath.ac.uk", "cm20145db115", "hNLbj926", "cm20145db115");

$this->catName=$catName;
// need to reference the my_sql connection from the query
$result = mysqli_query($wir3d, "SELECT CatName FROM Categories WHERE CatName = 
\'$this->catName\'")

throw new Exception("M001: invalid catName");

}

    I suggest posting the smallest and simplest code that demonstrates the problem.

      Write a Reply...