SQLSTATE[42S02]: Base table or view not found: 1146 Table 'sp.sign_ups' doesn't exist (SQL: insert into sign_ups
( first_name
, last_name
, email
, user_name
, password
, re_password
, contact
, updated_at
, created_at
) values (hassan, Mehedi, hassanmehedi@gmail.com, marlin, marlin, marlin, 01670654878, 2016-05-15 06:39:07, 2016-05-15 06:39:07))
I am facing above problem while clicking on submit button for sending sign up form data to database.
Here says 'Base table or view not found: 1146 Table 'sp.sign_ups' doesn't exist'. But in my 'sp' named database doesn't have any kind of table named 'sign_ups'. It named 'sign_up'......
Already I dropped the 'sign_up' table once and recreated it. Also restart the 'Apache' and 'MySQL' server. But nothing happened.
This is the controller SignUpController.php
<?php
namespace App\\Http\\Controllers;
use Request;
use App\\Http\\Requests;
use App\\sign_up;
class SignUpController extends Controller {
public function showSignUp()
{
return view('sign_up');
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
sign_up :: create(Request::all());
return 'test';
}
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
//
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
//
}
}
This is Model sign_up.php
<?php
namespace App;
use Illuminate\\Database\\Eloquent\\Model;
class sign_up extends Model { protected $fillable = ['first_name', 'last_name', 'email', 'user_name', 'password', 're_password', 'contact']; }
Can anybody help ?
You probably have a typo in your code that creates the "insert into..." query.
double check it.
if you don't have a typo there then post your code here
In your sign_up.php Model you just need add $table property,
protected $table = "sign_up";
Update sign_up.php Model code should look like this,
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class sign_up extends Model {
protected $table = 'sign_up';
protected $fillable = ['first_name', 'last_name', 'email', 'user_name', 'password', 're_password', 'contact'];
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.