vincej's avatar
Level 15

Fatal error: Uncaught TypeError: mb_strpos(): Argument #1 ($haystack) must be of type string, null given,

My application has been working for months without fault. Last week I changed a few formatting things within a blade file, and today I get this error. I have no clue where to start with this as none of the logic within the controllers of models was changed just the one blade file. Here is the full error, which I pulled off my dev machine. Any ideas anyone? Many thanks !!

Fatal error: Uncaught TypeError: mb_strpos(): Argument #1 ($haystack) must be of type string, null given, called in C:\laragon\www\KidsClub\vendor\laravel\framework\src\Illuminate\Support\Str.php on line 183 and defined in C:\laragon\www\KidsClub\vendor\symfony\polyfill-mbstring\bootstrap80.php:60 Stack trace: #0 C:\laragon\www\KidsClub\vendor\laravel\framework\src\Illuminate\Support\Str.php(183): mb_strpos(NULL, '/json') #1 C:\laragon\www\KidsClub\vendor\laravel\framework\src\Illuminate\Http\Concerns\InteractsWithContentTypes.php(16): Illuminate\Support\Str::contains(NULL, Array) #2 C:\laragon\www\KidsClub\vendor\laravel\framework\src\Illuminate\Http\Request.php(371): Illuminate\Http\Request->isJson() #3 C:\laragon\www\KidsClub\vendor\laravel\framework\src\Illuminate\Http\Request.php(435): Illuminate\Http\Request->getInputSource() #4 C:\laragon\www\KidsClub\vendor\laravel\framework\src\Illuminate\Http\Request.php(64): Illuminate\Http\Request::createFromBase(Object(Symfony\Component\HttpFoundation\Request)) #5 C:\laragon\www\KidsClub\public\index.php(55): Illuminate\Http\Request::capture() #6 {main} thrown in C:\laragon\www\KidsClub\vendor\symfony\polyfill-mbstring\bootstrap80.php on line 60

0 likes
4 replies
koramit's avatar

Mind to share snippet of blade code before and after changed ?

jlrdw's avatar

From the error

Argument #1 ($haystack) must be of type string, null given

A value (string) is missing, you have null.

Check network tab or dd and see what is going on.

1 like
vincej's avatar
Level 15

This happens when you login. The login controller directs to the "registration" view. That is the view which I changed. So, What I will do is comment out sections of the registration page until the error disappears, then slowly narrow it down to the offending line. I use PHPStorm, and usually it us very good at showing errors, but not this time. I will keep you informed of the result. Probably tomorrow.

AS always, Many thanks!!

vincej's avatar
Level 15

Ok, I found the error. When I upgraded to Php 8 I did not include the mbstring extension. So, error gone. However now I have an equally big error showing up in another part of my code concerning Msql not autoincrementing. I suspect my query is wrong. I will create a new question on that.

Many thanks!

Please or to participate in this conversation.