Fatal Error: Uncaught TypeError: Argument 1 passed to exception_handler ()

Advertisement

I want to import a csv file and therefore I write my PHP code, it works well, but as I add something, I get this error:

'' Fatal Error: Uncaught TypeError: Argument 1 passed to
exception_handler () ... ''

 $parts = explode(',', $tmp[6]); $fachrichtung = sistr($parts[1],'LA', true); if ($fachrichtung == 'LA'){ $fachrichtung = 'Lehramt' ; } else { $fachrichtung = substr($parts[0],strrpos($parts[0], " ") ); } 

And my query function works well without the above code, but I need that.

query: ..... '".utf8_encode (trim($fachrichtung,"""))."'

Why am I wrong?

The answer

There is no need to reinvent the wheel here. Try using the fgetcsv function instead. It should give you more predictable results and, hopefully, prevent the error from occurring in the first place.

In addition, it seems that it is complaining that you are moving beyond an exception to the exception manager.

You should be able to remedy this with the try-catch statement.

See also: http://php.net/manual/en/function.set-exception-handler.php

Related articles