【发布时间】:2023-04-09 17:18:02
【问题描述】:
我登录了我的 Heroku 应用程序,这是一个酒店评论应用程序:http://immense-beach-76879.herokuapp.com/。显然,它不会显示我在http://immense-beach-76879.herokuapp.com/reviews 输入的数据。它只是显示错误。它说整数是错误的选择,因为“kiki”应该是一个字符串,对吗?如果你需要看我的代码,这里是:https://github.com/kikidesignnet/hotelreviews。
这是我的错误:
SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for integer: "kiki" (SQL: select * from "reviews" where "user_id" in (1, kiki, k@k.com, ?, 2020-02-07 05:57:47, 2020-02-07 05:57:47) order by "created_at" desc limit 20)
我一直在关注本教程以了解 Laravel 以及 React/Laravel 如何协同工作:https://kaloraat.com/articles/laravel-react-crud-tutorial 和他们的 github 存储库:https://github.com/kaloraat/laravel-react-crud
这是我的迁移create_reviews_table.php:
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateReviewsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('reviews', function (Blueprint $table) {
$table->increments('id');
$table->integer('user_id')->unsigned()->index();
$table->string('name');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('reviews');
}
}
如您所见,这个应用程序应该注册一个新用户。然后当用户登录并提交对酒店的评论时,reviews.api 应该将数据保存在并在评论表单下方显示评论。
我只能看到表单正在工作,正在提交下面的数据但它没有显示任何数据......
【问题讨论】:
-
SELECT查询看起来明显错误,但您的代码不包含构建该查询的任何片段。请分享您的代码的正确部分,以及您的调试尝试 -
请张贴此错误指向的行
-
这是我的 github 仓库:github.com/kikidesignnet/hotelreviews
-
@TsaiKoga 怎么样?我不知道错误是什么。