小编run*_*ark的帖子

当 $request->validate 失败时 Laravel 抛出 404

我们正在为我们的应用程序创建一个 REST API。

网页.php

Route::post('add-new-student', 'StudentController@addNewStudent');
Run Code Online (Sandbox Code Playgroud)

学生控制器.php

Route::post('add-new-student', 'StudentController@addNewStudent');
Run Code Online (Sandbox Code Playgroud)

现在,当我们发送 JSON 响应时,如果出现错误,它不会转到 else 块,而是在邮递员中显示 404 页面。

我们不知道自己做错了什么!

笔记

  • 我们的路线是正确的(双重检查)
  • 在邮递员中,我们正在发送邮寄请求

php validation rest laravel

8
推荐指数
2
解决办法
6140
查看次数

这段代码有什么问题?html + php

我有一个简单的函数,它有两个参数,一个用于图像URL,另一个用于图像的属性

function image_found($url,$attributes)
{
    if(@getimagesize($url))
    {
        echo '<img src="'.$url.'" '.$attributes.'/>';
    }
    else
    {
        echo '<img src="'.base_url().'/site_images/image_not_found.svg" '.$attributes.'/>';
    }
}
Run Code Online (Sandbox Code Playgroud)

现在我要做的是创建一个可点击的图像,如果找到图像,现在这是html代码

echo '<div class="panel-body">';
echo '<div class="col-md-12 col-lg-12 col-sm-12 text-center">';
$url = base_url().'product_images/'.$result->product_image.'.'.$result->image_type;
$attributes = 'height="200px" width="100%"';
echo '<a href="product.com/full/url">'.image_found($url,$attributes).'</a>';
echo '</div>';
echo '</div>';
Run Code Online (Sandbox Code Playgroud)

这是我得到的输出

<div class="panel-body">
    <div class="col-md-12 col-lg-12 col-sm-12 text-center">
        <img src="http://localhost/nsc/product_images/7908076366784972032090.jpg" height="200px" width="100%"/>
        <a href="#"></a>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

我不知道这里有什么问题,我正在使用bootstrap

html php twitter-bootstrap

6
推荐指数
1
解决办法
118
查看次数

codeigniter应用程序在新应用程序中查看文件夹位置问题

Your view folder path does not appear to be set correctly. Please open the following file and correct this: index.php我收到这个错误,我不知道有什么问题,我从官方网站下载了rc3(发布候选人3),解压缩它,添加了资产文件夹和帮助,当我运行应用程序时,我收到了错误Your view folder path does not appear to be set correctly. Please open the following file and correct this: index.php,这是我的index.php文件代码,图像显示了文件夹结构

// index.php code
<?php
/**
 * CodeIgniter
 *
 * An open source application development framework for PHP
 *
 * This content is released under the MIT License (MIT)
 *
 * Copyright (c) 2014 - 2015, British …
Run Code Online (Sandbox Code Playgroud)

php codeigniter codeigniter-3

5
推荐指数
1
解决办法
1万
查看次数

语法错误,无法识别的表达式:option [value = property name]

我有一个看起来像这样的数据表

<datalist id="properties">
       <option value="property name"></option>
       <option value="property"></option>
</datalist>
Run Code Online (Sandbox Code Playgroud)

现在,我正在使用此代码查找用户输入的值在列表中的位置:

var user_property = $('#user_property').val().toLowerCase(); // taken from input type with id user_property
var pro = $('#properties').find("option[value="+user_property.replace(' ','-')+"]");
if(pro != null && pro.length > 0)
{
    // run some code
}
else
{
    // show error popup
}
Run Code Online (Sandbox Code Playgroud)

我收到了错误 var pro = $('#properties').find("option[value="+user_property.replace(' ','-')+"]");

错误代码说 Syntax error, unrecognized expression: option[value=property name]

如何摆脱这个错误?

javascript jquery datalist

4
推荐指数
1
解决办法
2万
查看次数