Welcome Guest, Not a member yet? Register   Sign In
Codeigniter not showing helpful error messgaes
#1

Codeigniter normally used to show helpful error messages but for some unknown reasons, all it shows is

    Uncaught ErrorException: htmlspecialchars() expects parameter 1 to be string, resource given in C:\xampp\htdocs\app\Views\errors\html\error_exception.php:182 Stack trace: #0 [internal function]: CodeIgniter\Debug\Exceptions->errorHandler(2, 'htmlspecialchar...', 'C:\\xampp\\htdocs...', 182, Array) #1 C:\xampp\htdocs\app\Views\errors\html\error_exception.php(182): htmlspecialchars(Resource id #23, 8, 'UTF-8') #2 C:\xampp\htdocs\system\Debug\Exceptions.php(299): include('C:\\xampp\\htdocs...') #3 C:\xampp\htdocs\system\Debug\Exceptions.php(172): CodeIgniter\Debug\Exceptions->render(Object(ParseError), 500) #4 [internal function]: CodeIgniter\Debug\Exceptions->exceptionHandler(Object(ParseError)) #5 {main} thrown

I have NO idea what is going on.Whether it is a parse error, synat error etc, that is all it ever shows now.Please help

Ps: this happened after installing some composer pacakages
Reply
#2

(This post was last modified: 10-09-2020, 06:46 AM by captain-sensible.)

ok well somewhere you are using:
Code:
htmlspecialchars($input,ENT_QUOTES ,'UTF-8',True);

so as you can see in the example above the first parameter passed has to be a string. Funny enough i've just been
playing with along with esc();

So say you have a form with a text input called 'title' and you get the text typed into that text box in a controller
using :

Code:
$title = $this->request->getVar('title');

well you might want to process it and change  a double quotation to " then its along the lines of:

Code:
htmlspecialchars($title,ENT_QUOTES );

Now for max info open up Logger.php located app/Config and set to 9

Make sure in .env :

CI_ENVIRONMENT = development





or if your not using that but in index.php in public
$_SERVER['CI_ENVIRONMENT'] = 'development';

Do you have the tool bar showing bottom of web page ?

image shows what error i get , tells me line 20 where i put an integer of 1

Attached Files Thumbnail(s)
   
Reply
#3

(This post was last modified: 10-10-2020, 12:04 PM by paulbalandan.)

The error is clear. You are passing a resource type as the first parameter of htmlspecialchars, which usually accepts a string. Please check the variable you are passing to the first param.

Ok. Scrap my last comment. The error is from the built in error exception file.

Do you have somewhere in your code that you defined a constant equivalent to a resource? Something like define('STREAM', STDOUT); or define('MY_FILE', fopen('path/to/file', 'rb'));

The problem is that the file is printing all defined constants and escaping them using htmlspecialchars. But somewhere a user defined constant is set to a resource so this causes a fatal error.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB