gpt4 book ai didi

php - 为什么在我的 POST 中呈现此 html 错误?

转载 作者:搜寻专家 更新时间:2023-10-31 21:13:55 26 4
gpt4 key购买 nike

我有一个可用性日历,我正尝试使用 Laravel 将其发布到我的数据库。当我转储我的帖子时,我得到了这个..

string(1440) "s:1430:"2012-11-06;;1;;888,2012-11-07;;1;;888,2012-11-08;;
1;;888,2012-11-09;;1;;888,2012-11-10;;1;;888,2012-11-11;;1;;888,2012-11-12;;
1;;888,2012-11 13;;1;;888,2012-11-14;;1;;888,2012-11-15;;1;;888,2012-11-16;;1;;
888,2012-11-17;;1;;888,2012-11-18;;1;;888,2012-11-19;;1;;888,2012-11-20;;1;;888,
2012-11-21;;1;;888,2012-11-22;;1;;888,2012-11-23;;1;;888,2012-11-24;;1;;888,
2012-11-25;;1;;888,2012-11-26;;1;;888,2012-11-27;;1;;888,2012-11-28;;2;;0,array(1)
{["availability"]=>string(973) "s:964:"2012-11-05;;1;;888,2012-11-29;;1;;
888,2012-11-30;;1;;888,array(1) {["availability"]=>string(12) "availability"}

<html><h2>Unhandled Exception</h2><h3>Message:</h3><pre>Error rendering view:
[layouts.admin] Undefined variable: title</pre><h3>Location:</h3>
<pre>/Users/corymjacik/Sites/shipwatch_v2.1/storage/views/33f72cb6519c7f146dc8d6af4b948300 on line 5</pre><h3>Stack Trace:</h3>
<pre>#0 /Users/corymjacik/Sites/shipwatch_v2.1/laravel/laravel.php(40):
Laravel\Error::native(8";"}
<html><h2>Unhandled Exception</h2><h3>Message:</h3>
<pre>Error rendering view: [layouts.admin]Undefined variable: title</pre>
<h3>Location:</h3>
<pre>/Users/corymjacik/Sites/shipwatch_v2.1/storage/views/33f72cb6519c7f146dc8d6af4b948300
on line 5</pre><h3>Stack Trace:</h3> <pre>#0 /Users/corymjacik/Sites/shipwatch_v2.1/laravel/laravel.php(40):
Laravel\Error::native(8";"

可能导致此错误的原因是什么,为什么它包含在我对数据库的 POST 中?下面是我的 Controller 代码。一切正常,就像这样。我能够将该字符串发布到数据库(我使用 serialize() 将其从数组转换为字符串),而且我还能够从数据库中获取它并在前端显示得很好。这些错误似乎没有什么不同,但我只是觉得我做错了什么。

public function post_availability_save()
{
$availability = serialize(Input::get('dop_booking_calendar'));
//var_dump($availability);die;

$id = Auth::user()->id;

Availability::update($id, array(
'user_id' => Auth::user()->id,
'availability' => $availability
));
return Redirect::to('admin');
}

public function get_availability_load()
{
$id = Auth::user()->id;

$availability = array(
'availability' => Availability::find($id)->availability
);

var_dump($availability);

}

编辑多弄乱它,它也倾倒了我的 html 布局的开头......任何人都知道是什么原因造成的?我会深入挖掘。编辑 2012 年 11 月 13 日

//*This is what ends up in my database (Type:TEXT) //
,2012-11-13;;1;;1,2012-11-14;;1;;1,2012-11-15;;1;;1,2012-11-16;;1;;1,2012-11-
17;;1;;1,2012-11-18;;1;;1,2012-11-19;;1;;1,2012-11-20;;1;;1,2012-11-21;;1;;1,2012
-11-22;;1;;1,2012-11-23;;1;;1,2012-11-24;;1;;1,2012-11-25;;1;;1,2012-11-26;;1;;1,
2012-11-27;;1;;1,2012-11-28;;1;;1,Array
(
[availability] => 1
)
<html><h2>Unhandled Exception</h2>
<h3>Message:</h3>
<pre>Error rendering view: [layouts.admin] Undefined variable: title</pre>
<h3>Location:</h3>
<pre>/Users/cory/Sites/shipwatchpoint_v2.1/storage/views/e2b30637bfaa9d210e31baf35870d230 on line 5</pre>
<h3>Stack Trace:</h3>
<pre>#0 /Users/corymjacik/Sites/shipwatchpoint_v2.1/laravel/laravel.php(40): Laravel\Error::native(8

// *layouts.admin.blade.php //
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>{{ $title }}</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">

<!-- CSS -->
{{ HTML::style('css/bootstrap.css') }}
{{ HTML::style('css/jquery.dop.BookingCalendar.css') }}
{{ HTML::style('css/app.css') }}

<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->

<!-- Fav and touch icons -->
<link rel="shortcut icon" href="/img/ico/favicon.ico">

</head>
<body>

<div class="container-fluid">
{{ $content }}
</div>

<!-- JS -->
<!-- Placed at the end of the document so the pages load faster -->
{{ HTML::script('http://code.jquery.com/jquery-1.8.2.min.js') }}
{{ HTML::script('js/bootstrap.js') }}
{{ HTML::script('js/app.js') }}
{{ HTML::script('js/jquery.dop.BookingCalendar.js') }}

</body>
</html>

//*admin controller (public restful is set to true)//
public function get_index()
{
$id = Auth::user()->id;
$unit = array(
'unit' => Unit::find($id),
'unit_admin' => Unit::find($id)->user,
//'availability' => Availability::all() added this and it still showed errors
);

//var_dump($unit);die;

$this->layout->title = 'Admin Profile';
$this->layout->nest('content', 'admin.index', $unit);
}

public function post_availability_save()
{
//$availability = serialize(Input::get('dop_booking_calendar'));
$availability = Input::get('dop_booking_calendar');
//var_dump($availability);die;

$id = Auth::user()->id;

Availability::update($id, array(
'user_id' => Auth::user()->id,
'availability' => $availability
));
return Redirect::to('admin');
}

public function get_availability_load()
{
$id = Auth::user()->id;

$availability = array(
'availability' => Availability::find($id)->availability
);

var_dump($availability);

}

最佳答案

return Redirect::to('admin');

发送 $title 中的“标题”或将其设置在布局中,就像您在 action_index() 中所做的那样

return Redirect::to('admin')->with('title','supercooltitle');

return Redirect::to('admin')->with_title('supercooltitle');

然后您的 View 可以获取 $title 并停止显示 undefined reference 。

其他选项是将其设置在类似于您对索引所做的布局上。

关于php - 为什么在我的 POST 中呈现此 html 错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13240269/

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