gpt4 book ai didi

mysql - SQLSTATE[42S22] : Column not found: 1054 Unknown column '1' in 'field list' (SQL: select `1` from `phonebooks` )

转载 作者:行者123 更新时间:2023-11-29 06:55:17 25 4
gpt4 key购买 nike

当我尝试将数据传递到编辑页面时,我收到此错误。请帮助我

Connection.php 第 729 行中的 QueryException:SQLSTATE[42S22]:未找到列:1054“字段列表”中未知列“1”(SQL:从电话簿中选择1)

PhonebookController.php

public function edit($id)
{
$data = Phonebooks::all($id);
echo"$data";
return view('phonebook.edit', compact('$data'));
}

edit.blade.php

<html>
<body>
<form method="POST" action="{{ URL::to('phonebook') }}" >
<input type="text" name="id" value="{{$id}}"/>
<input type="text" name="phoneNo" value="{{old('phoneNo')}}"/>
<input type="text" name="email" value="{{old('email')}}" />
<input type="submit" value="Save"/>
<input type="hidden" name="_token" value="{{ csrf_token() }}">
</form>

</body>
</html>

最佳答案

你应该尝试这个:

 public function edit($id)
{
$data = Phonebooks::find($id);

return view('phonebook.edit', compact('data'));
}

<html>
<body>
<form method="POST" action="{{ URL::to('phonebook') }}" >
<input type="text" name="id" value="{{$data->id}}"/>
<input type="text" name="phoneNo" value="{{old('phoneNo')}}"/>
<input type="text" name="email" value="{{old('email')}}" />
<input type="submit" value="Save"/>
<input type="hidden" name="_token" value="{{ csrf_token() }}">
</form>

</body>
</html>

关于mysql - SQLSTATE[42S22] : Column not found: 1054 Unknown column '1' in 'field list' (SQL: select `1` from `phonebooks` ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45912762/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com