Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/413.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/227.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript SQLSTATE[23000]:完整性约束冲突:1048 laravel 5.7_Javascript_Php_Laravel_Phpmyadmin_Laravel 5.7 - Fatal编程技术网

Javascript SQLSTATE[23000]:完整性约束冲突:1048 laravel 5.7

Javascript SQLSTATE[23000]:完整性约束冲突:1048 laravel 5.7,javascript,php,laravel,phpmyadmin,laravel-5.7,Javascript,Php,Laravel,Phpmyadmin,Laravel 5.7,我在Laravel 5.7中遇到错误: 照亮\数据库\查询异常 SQLSTATE[23000]:完整性约束冲突:1048列“名称”不能为空(SQL:插入存储区(名称,矩阵,电话,电子邮件,密码,更新时间,创建时间)值(?,,,,,,,,,,,,,,,,,,,2019-10-01 16:49,2019-10-01 16:29:49) 这是我的表格: <!DOCTYPE html> <html> <head> @section('title', 'Sign

我在Laravel 5.7中遇到错误:

照亮\数据库\查询异常 SQLSTATE[23000]:完整性约束冲突:1048列“名称”不能为空(SQL:插入
存储区
名称
矩阵
电话
电子邮件
密码
更新时间
创建时间
)值(?,,,,,,,,,,,,,,,,,,,2019-10-01 16:49,2019-10-01 16:29:49)

这是我的表格:

<!DOCTYPE html>
<html>
<head>
    @section('title', 'Sign up for customer page')
</head>
<body class="text-center">
@extends('layout.app')

@section('content')

@endsection
@include('include.navbar')
<form class="form-signup" action="{{URL:: to('/store')}}" method="post">
  @csrf

  <h1 class="h3 mb-3 font-weight-normal">Please sign up as customer</h1>
  <label for="inputname" class="sr-only">Name</label>
  <input type="text" id="inputname" class="form-control" placeholder="Name" required>
  <label for="inputmatric" class="sr-only">ID matric</label>
  <input type="text" id="inputmatric" class="form-control" placeholder="ID matric" required>
  <label for="inputphon" class="sr-only">Phone No</label>
  <input type="text" id="inputphon" class="form-control" placeholder="Phone No" required>
  <label for="inputemail" class="sr-only">E-mail</label>
  <input type="text" id="inputemail" class="form-control" placeholder="E-mail" required>
  <label for="inputpassword" class="sr-only">Password</label>
  <input type="text" id="inputpassword" class="form-control" placeholder="Password" required>


  <button class="btn btn-lg btn-primary btn-block"  type="submit">Sign up</button>
  <p class="mt-5 mb-3 text-muted">&copy; 2017-2019</p>
</form>

</html>
这就是迁移:

<?php
//create the customer table
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateStoresTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('stores', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string ('name');
            $table->integer ('matric');
            $table->string ('phone');
            $table->string ('email');
            $table->string ('password');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('stores');
    }
}

您试图在名称列中保存空值,即使它是必需的。

您的html表单中缺少
name
属性。如果没有此属性,您的输入数据将不会传递到控制器,因此您将获得空值。因此,将
name
属性添加到输入字段中

<label for="inputname" class="sr-only">Name</label>
<input type="text" id="inputname" name="name" class="form-control" placeholder="Name" required>
<label for="inputmatric" class="sr-only">ID matric</label>
<input type="text" id="inputmatric" name="matric" class="form-control" placeholder="ID matric" required>
<label for="inputphon" class="sr-only">Phone No</label>
<input type="text" id="inputphon" name="phone" class="form-control" placeholder="Phone No" required>
<label for="inputemail" class="sr-only">E-mail</label>
<input type="text" id="inputemail" name="email" class="form-control" placeholder="E-mail" required>
<label for="inputpassword" class="sr-only">Password</label>
<input type="text" id="inputpassword" name="password" class="form-control" placeholder="Password" required>

您应该使用
name=“namehere”
e、 g


您也可以采取以下步骤绕过Laravel网站中的此错误:-

  • 在路径
    \config\

  • 位于路径
    \app\Http\

  • // \Illumb\Foundation\Http\Middleware\ConvertEmptyStringsToull::class


    希望它能对将来的人有所帮助。

    您的输入没有
    名称
    属性,因此不会通过表单传递。因此,如何解决此问题我想将名称存储到数据库中我相信从UserController类中的字段检索值时出错,尝试检查是否可以检索输入值,或者输入值是否返回null或空。-->$store->name=$request->input('name');这样,您就可以通过$request在控制器中访问它$请求->名称,或者如果您将输入命名为“email”,那么$request->email也可以是请求('name')等。。
    <label for="inputname" class="sr-only">Name</label>
    <input type="text" id="inputname" name="name" class="form-control" placeholder="Name" required>
    <label for="inputmatric" class="sr-only">ID matric</label>
    <input type="text" id="inputmatric" name="matric" class="form-control" placeholder="ID matric" required>
    <label for="inputphon" class="sr-only">Phone No</label>
    <input type="text" id="inputphon" name="phone" class="form-control" placeholder="Phone No" required>
    <label for="inputemail" class="sr-only">E-mail</label>
    <input type="text" id="inputemail" name="email" class="form-control" placeholder="E-mail" required>
    <label for="inputpassword" class="sr-only">Password</label>
    <input type="text" id="inputpassword" name="password" class="form-control" placeholder="Password" required>
    
    $this->validate($request,[
        'name'=> 'required',
        'matric'=> 'required',
        'phone'=> 'required',
        'email'=>'required',
        'password'=> 'required'
    ]);
    
    <input type="text" id="inputname" name="name" class="form-control" placeholder="Name" required>