laravel syntax error, enexpected ',' , expecting ';' [closed] - laravel

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
I tried to fix this but don't know how
public function render()
{
return view('livewire.home')->extends('layouts.app')->section('content'),[
'products' => Product::take(3)->get()
];
It said that the syntax is error,
unexpected ',', expecting ';'
I'm newbie to Laravel so I couldn't write the correct syntax. Please let me know.

As you can see in the docs, to pass variables to the view, you need to set the second parameter in the method view() as the array of data.
public function render()
{
return view('livewire.home', [
'products' => Product::take(3)->get()
])->extends('layouts.app')->section('content');
}

Related

r.PostForm() works only if I call before r.PostFormValue() [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 days ago.
Improve this question
As the title say, I have a code like this:
//if i don't use this line r.postform() don't works and return absolute nothing.
//html form works correctly
// I don't need to call r.PostFormValue for every key, just one
fmt.Println(r.PostFormValue("oldpass"))
if r.PostForm.Has("oldpass") && r.PostForm.Has("newpass1") && r.PostForm.Has("newpass2")
{ //if i don't call r.PostFormValue() the program stop before the if }
}
Make no sense to me... Also I remember to have used it without in the past, so I don't think it depend on parsing the value... What could be?

Call to undefined function getClientOriginalName() in Laravel 8 [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed last year.
Improve this question
I want to use the function getClientOriginalName() for making a new name for the photo I take from the user. But as I said before, it displays an error that says that this function is undefined.
$pic = $request->photo;
$newPic = time().$pic.getClientOriginalName();
The method getClientOriginal name exists on the UploadedFile instance. To get the instance you should get by the file() method from $request object
$pic = $request->file('photo');
$newPic = time().$pic->getClientOriginalName();

syntax error near unexpected token `(' in rust [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
I typed my first code in rust. The helloworld. But I got an error when I tried to run it.
fn main() {
println!("Hello world");
}
I tried to run using './hellworld.rs'
But it showed,
syntax error near unexpected token `('
`fn main() {'
I was using powershell. But used the wrong command ./helloworld.rs
Instead I tried ./helloworld and ./helloworld.exe. Both worked.

Check if Hash is included in output [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I am trying to check if a specific element is included in an output. I run:
results.include? {"_id"=>{"car_id"=>44, "page"=>"5"}, "summarized_time"=>100}
but I get an error:
Syntax error, unexpected =>, expecting '}'
What did I do wrong?
The problem is that the curly brackets in this case are interpreted as start of a block. Just put () around:
results.include?({"_id"=>{"car_id"=>44, "page"=>"5"}, "summarized_time"=>100})

Prepared Statement does not insert [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Improve this question
I am new to JDBC and trying following code. Could not find the error in it:
try{
Connection con = ConnectionProvider.getCon();
stmt=con.prepareStatement("insert into create_request values((select count(reqno) from create_request)+1,?,?,?,?,?)");
stmt.setString(1,obj_Leaverequest.getUser_name());
stmt.setString(2,obj_Leaverequest.getLeave_Type());
stmt.setInt(3,obj_Leaverequest.getLeave_Units());
stmt.setString(4,obj_Leaverequest.getLeave_Reason());
stmt.setString(5,"pending");
count=stmt.executeUpdate();
if(count>0){
status=true;
}
}
Update:
If I replace my code like this it works:
String sqQuery="insert into create_request values (?,?,?,?,?,?)";
stmt=con.prepareStatement(sqQuery);
stmt.setString(1,"(select count(reqno) from create_request)+1");
stmt.setString(2,obj_Leaverequest.getUser_name());
stmt.setString(3,obj_Leaverequest.getLeave_Type());
stmt.setInt(4,obj_Leaverequest.getLeave_Units());
stmt.setString(5,obj_Leaverequest.getLeave_Reason());
stmt.setString(6,"pending");
Getters are working fine, I could print their values. I guess I am wrong with the query. Please point out my mistake. Thanks in advance!!
String sqQuery="insert into create_request values (?,?,?,?,?,?)";
stmt=con.prepareStatement(sqQuery);
stmt.setString(1,"(select count(reqno) from create_request)+1");
stmt.setString(2,obj_Leaverequest.getUser_name());
stmt.setString(3,obj_Leaverequest.getLeave_Type());
stmt.setInt(4,obj_Leaverequest.getLeave_Units());
stmt.setString(5,obj_Leaverequest.getLeave_Reason());
stmt.setString(6,"pending");
Check for the "?" prepared statements index . You have 6 , but you need only 5
Hope this helps

Resources