Laravel 5.3 - htmlspecialchars() expects parameter 1 to be string
I think your $user->website
is empty/blank.
If you look at the url()
helper method, Laravel will return an instance of UrlGenerator
if $path
is null.
So in your case if $user->website
is empty, you'd get UrlGenerator
back and thus your error about htmlspecialchars
getting an object.
One simple solution would be to wrap your html chunk with a check:
@if($user->website)
<li>
...
</li>
@endif
Laravel htmlspecialchars() expects parameter 1 to be string, object given in my project?
Just change the array key from message
to messages
in your controller like below:
$data = array(
'messages' => $request->message
);
and also in the blade print it as {{$messages}}
A $message variable is always passed to e-mail views, and allows
the inline embedding of attachments. So, it is best to avoid passing a
message variable in your view payload.
Check the note in this link: http://laravel.com/docs/5.0/mail#basic-usage
htmlspecialchars() expects parameter 1 to be string, array given in Laravel
{{}}
will be converted to echo()
by Blade template engine. And you're trying to echo the array as a string.
You may convert it to JSON:
var value = '{{ json_encode($sliderImageDataArray) }}';
If it's a Laravel collection or a model:
var value = '{{ $sliderImageData->toJson() }}';
htmlspecialchars() expects parameter 1 to be string laravel
The second value for textarea() and text() must be a default value, try this:
Form::textarea('desc', '', ['rows'=>'3'
Form::text('name', '', ['class'=>'form-control'
htmlspecialchars() expects parameter 1 to be string, array given
OK I finally have an answer for this problem....it seems like something has changed in Laravel 5.3 and if you want to have a name with array like this
{!! Form::label('title', '* Eventname: ', ['class' => 'control-label']) !!}
{!! Form::text('title[]', null, ['class' => 'form-control', 'required') !!}
You must put [0] something in brackets 'indices' like this:
{!! Form::text('title[0]', null, ['class' => 'form-control', 'required') !!}
and then in validation use
title.*
for rule
UPDATE
Because i use dynamic form that can be expanded and new form fields added (optionally) i needed to put [] array notation for a name but actually if you already have hard coded many fields with the same name like item[]
you don't have to put [0] indices inside. The validation will work for them.
The problem comes only if you have a single input field and you put [] array notation along the name for example 'item[]'
this will trigger the error if any validation rule is broken...
htmlentities() expects parameter 1 to be string, object given
The problem is in PagesController
inside the Mail::send
.
'message' => $request->get('message');
You are using the variable name 'message'
and it should be avoided.
Note: A $message variable is always passed to e-mail views, and allows
the inline embedding of attachments. So, it is best to avoid passing a
message variable in your view payload.
source: http://laravel.com/docs/5.0/mail#basic-usage in the first note.
You might need to change the variable name to be something else.
'bodyMessage' => $request->get('message');
And don't forget the change the variable name in your contact.blade.php
as well
<p>
Name: {{ $name }}
</p>
<p>
{{ $email }}
</p>
<p>
{{ $phone }}
</p>
<p>
{{ $bodyMessage }} // This line.
</p>
Related Topics
Selecting Rows Where a Field Is Null Using PHP Pdo Prepared Statements and MySQL
How to Get a List of MySQL Databases in PHP Using Pdo
PHP MySQL Set Connection Timeout
Facebook Oauthexception: "User Hasn't Authorized the Application to Perform This Action"
Php: How to Check If the Client Is Local
How to Grab All Variables in a Post (Php)
Is This Mail() Function Safe from Header Injection
Calling a Controller Function in Another Controller in Codeigniter
Can Mongodb and Its Drivers Preserve the Ordering of Document Elements
Laravel 5 Isdirty() Always Returns False
PHP $String{0} VS. $String[0];
Check If Username Exists in MySQL Table via PHP
Set the Option Available for Select Based on Another Select PHP
Call to Undefined Function Oci_Connect, PHP_Oci8_12C.Dll, Windows 8.1, PHP5.6.6