Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

MaxGovers's avatar

syntax error, unexpected token "=>", expecting ")"

Having this error, cant seem to find a solution..

{{Form::open (array ('url' => 'logincheck'))}}

    <p> {{Form::text ('username', string ('placeholder'=>'Username','maxlength'=>30))}} </p>

    <p> {{Form::password ('password', string('placeholder'=>'Password','maxlength'=>30))}} </p>

    <p> {{Form::submit ('Submit')}} </p>

{{Form::close ()}}
0 likes
18 replies
MichalOravec's avatar
<p> {{Form::password ('password', string('placeholder'=>'Password','maxlength'=>30))}} </p>

change to

<p>{{ Form::password('password', ['placeholder '=> 'Password', 'maxlength' => 30 ]) }}</p>

And same for username.

2 likes
MaxGovers's avatar

Im completely screwing up my code, the code you mentioned does seem to fix the whole issue.

{{Form::open (array ['url' => 'logincheck']) }}

    <p> {{Form::text ('username', ['placeholder'=> 'Username','maxlength' =>30]) }} </p>

    <p>{{ Form::password('password', ['placeholder '=> 'Password', 'maxlength' => 30 ]) }}</p>

    <p> {{Form::submit ('Submit')}} </p>

    {{Form::close ()}}
MichalOravec's avatar
{{Form::open (array ['url' => 'logincheck']) }}

change to

{{ Form::open(['url' => 'logincheck']) }}

Use classic html form instead of laravel collective, I said it to you in a previous thread.

MaxGovers's avatar

seem to have the same issue as i had before..

htmlspecialchars(): Argument #1 ($string) must be of type string, array given
MaxGovers's avatar

There was this guy his tutorial and i followed it, apparently it wasnt a good tutorial after all.

MichalOravec's avatar
Level 75

Just use html for forms, your code it's same as

<form action="/logincheck" method="POST">
    @crsf

    <input type="text" name="username" placeholder="Username" maxlength="30">

    <input type="password" name="password" placeholder="Password" maxlength="30">

    <button type="submit">Submit</button>
</form>
1 like
MaxGovers's avatar

Thank you so much this works, only the @crsf just shows as a p tag idk why

justsomeone's avatar

@MichalOravec Hi can you help me with something im actually a student so i just ask about that $uitslagen=[ [ 'thuis' => 'FC Twente', 'uit' => 'FC Utrecht', 'uitslag' => [0,1] ] [ 'thuis' => 'FC Twente', 'uit' => 'FC Volendam', 'uitslag' => [3,1] ] [ 'thuis' => 'FC Emmen', 'uit' => 'Feyenoord', 'uitslag' => [0,3] ] [ 'thuis' => 'Vitesse', 'uit' => 'FC Twente', 'uitslag' => [1,1] ] ]

he is give error : Parse error: syntax error, unexpected token "=>", expecting "]" and idk what is should to do

tykus's avatar

@justsomeone you're missing some commas

$uitslagen = [
  [
    'thuis' => 'FC Twente',
    'uit' => 'FC Utrecht',
    'uitslag' => [0, 1],
  ], // here
  [
    'thuis' => 'FC Twente',
    'uit' => 'FC Volendam',
    'uitslag' => [3, 1],
  ], // here
  [
    'thuis' => 'FC Emmen',
    'uit' => 'Feyenoord',
    'uitslag' => [0, 3],
  ], // here
  [
    'thuis' => 'Vitesse',
    'uit' => 'FC Twente',
    'uitslag' => [1, 1],
  ],
];

1 like
Sergiu17's avatar
string('placeholder'=>'Password','maxlength'=>30)

something is wrong here

Tray2's avatar

First of all don't use LaravelCollective forms. Learn to do it with regular html.

{{Form::password ('password', string('placeholder'=>'Password','maxlength'=>30))}}

in you string you use array syntax. Try wrapping 'placeholder'=>'Password','maxlength'=>30 with square brackets

['placeholder'=>'Password','maxlength'=>30]
Binlagche's avatar

Having this error too, Parse error: syntax error, unexpected token "if", expecting "]" I don't know what is needed, this is the code if (!isset($dom[$key]['attribute']['size']) AND !isset($dom[$key]['style']['font-size'])) {

Snapey's avatar

@Binlagche This is a completely different topic

learn to format code in your questions

What language is this in?

Binlagche's avatar

I am sorry for the off-topic question. I am completely new, trying to find a solution to what looks the same to me. The language I believe is PHP

Snapey's avatar

@Binlagche if the error is at the start of your code, it usually means that you have something wrong on the previous line (not shown)

So create your own question and provide a larger code block and some context

Use an IDE that can show syntax errors in your editor

Please or to participate in this conversation.