首页 \ 问答 \ JShint:期望一个赋值或函数调用,而是看到一个表达式(JShint :Expected an assignment or function call and instead saw an expression)

JShint:期望一个赋值或函数调用,而是看到一个表达式(JShint :Expected an assignment or function call and instead saw an expression)

我有这条线:

$scope.campaingstartDate;

并且JSHint显示以下消息:

$scope.campaingstartDate;
^ Expected an assignment or function call and instead saw an expression.

我是Angular JS和JSHint的新手,所以我该怎么做才能解决这个问题呢?


I have this line:

$scope.campaingstartDate;

And JSHint shows the following message:

$scope.campaingstartDate;
^ Expected an assignment or function call and instead saw an expression.

I am new to Angular JS and JSHint, so what should I do to fix this problem?


原文:https://stackoverflow.com/questions/39032868
更新时间:2023-04-21 07:04

最满意答案

不要从其他文件修改PHP脚本 - 这是一个坏主意。
有更好的解决方案 - 幸运的是简单的解决方案。 从URL字符串中获取用户需要的内容。 查询位于$_GET全局数组中。

//default sort values
$sortby = "Price";
$order = "DESC";
if(isset($_GET['sortby'])){ //if theres a sortby query in the URL
    $sortby = mysql_real_escape_string($_GET['sortby']);
}
if(isset($_GET['order'])){ //if user provided elements order in the URL
    $order = mysql_real_escape_string($_GET['order']);
    if($order == "DESC"){
        $order = "DESC";
    }else{
        $order = "ASC";
    }
}


$db_handler = new DB();
$query = "SELECT `Title`, `Autor`, `Price`, `Cover`, `Brief_desc`, `id` FROM `book` ORDER BY $sortby $order";

这个例子的一个注释: 总是使用ESCAPING ! (mysqli_real_escape_string更好,但需要mysqli链接(引用你的数据库,我没有一个,我不知道你的数据库类提供了什么方法,变量))。
他们阻止你进行SQL注入

链接将是

<a href="index.php?sort=Price&order=ASC">Sort from least exspensive</a> 
<a href="index.php?sort=Price&order=DESC">Sort from most exspensive</a>

Dont ever modify php scripts from other files - thats a bad idea.
There are better solutions - Fortunately the simple ones. Just get what user need from URL string. The queries are in the $_GET global array.

//default sort values
$sortby = "Price";
$order = "DESC";
if(isset($_GET['sortby'])){ //if theres a sortby query in the URL
    $sortby = mysql_real_escape_string($_GET['sortby']);
}
if(isset($_GET['order'])){ //if user provided elements order in the URL
    $order = mysql_real_escape_string($_GET['order']);
    if($order == "DESC"){
        $order = "DESC";
    }else{
        $order = "ASC";
    }
}


$db_handler = new DB();
$query = "SELECT `Title`, `Autor`, `Price`, `Cover`, `Brief_desc`, `id` FROM `book` ORDER BY $sortby $order";

One note for this example: ALWAYS USE ESCAPING! (The mysqli_real_escape_string is better, but requires mysqli link (reference to your db, i dont have one and i dont know what methods,variables your DB class provides)).
They are preventing you from SQL Injection

Links will be

<a href="index.php?sort=Price&order=ASC">Sort from least exspensive</a> 
<a href="index.php?sort=Price&order=DESC">Sort from most exspensive</a>

相关问答

更多
  • 不,你不需要有UML文档,但是如果使用得当,我可以非常有帮助。 三种帮助我很多的图表是: [1](对象和)类图 从此开始。 在简单的HTML页面的情况下,它非常容易。 只需在课堂上画出您的网站将要拥有的每个特定页面。 在这个例子中,我们有一个网站商店,它有一个“主”页面(index.html)和一个“产品”页面。 对于静态HTML页面,您可以跳过“属性”,“方法”。 .............................................. ..+----------------+..+- ...
  • 没有一个完美的答案,因为有太多的方法可以做到这一点。 一个好的解决方案是将视图(HTML)与逻辑(PHP)分开。 可能MVC将是一个很好的答案。 如果你只想练习: 创建一个文件夹并将所有HTML文件放入该文件夹。 然后你有你的PHP文件,其中包含一个函数(甚至可能是一个方法),它调用你想要显示的HTML内容。 如果您的HTML内容还包含PHP,最好不要将其命名为myFile.php 。 在这种情况下,将其myFile.phtml ,因此您可以清楚地知道它是HTML,但它的一部分也是PHP。 There is ...
  • 我尝试了几种方法 Web服务的TechWriter :真的很强大,但HTML输出(见评论)多文件。 另外,评论表明它已经退休了,但事实并非如此。 XML编辑器 :它不处理嵌入式模式。 Altova XML Spy :它不处理匿名类型。 并结束了对我的需求调整WSDL查看器。 I tried several alternatives TechWriter for Web Services: Really powerful, but HTML output was (see comment ...
  • 正如评论中所提到的,在其当前形状中,您的脚本不能比查询的API的响应时间更快。 您没有对API进行任何说明,因此无法保证该区域的加速。 但是,如果该API始终为同一查询返回相同的结果,则可以通过实现结果缓存来缓解此问题。 基本上,您应该在持久化数组中存储由其参数索引的查询结果,并且每次进行查询时,检查结果是否已经存在。 您可以选择将该数组作为会话值, 数据库或基于内存的缓存机制(如memcache) 。 每种方法都有利有弊,选择一种解决方案也取决于API: 基于会话的缓存将受到每个客户端的限制,这将大大降低 ...
  • 尝试键入而不是像127.0.0.1/index.php这样的localhost 127.0.0.1 Try typing instead of localhost 127.0.0.1 like 127.0.0.1/index.php
  • 不要从其他文件修改PHP脚本 - 这是一个坏主意。 有更好的解决方案 - 幸运的是简单的解决方案。 从URL字符串中获取用户需要的内容。 查询位于$_GET全局数组中。 //default sort values $sortby = "Price"; $order = "DESC"; if(isset($_GET['sortby'])){ //if theres a sortby query in the URL $sortby = mysql_real_escape_string($_GET['s ...
  • 您需要数据库的帮助才能将您的产品分成几组。 基本上,数据库将有一个“Products”表,表中的每一行都代表一个产品。 您将使用PHP来请求数据库检索第一个/下一个N行,然后在每个返回的行周围写出适当的HTML以创建产品列表。 网上有很多教程可以帮助你练习。 祝你好运! You need the help of a database to paginate your products in sets. Basically, the database will have a "Products" table, ...
  • 大多数PHP框架都具有(或实现扩展功能)所需的功能。 例如,Cakephp有所谓的辅助类,其中一些用于生成html内容。 例子(cakePHP): echo $this->Form->input($params); 这会根据传递给它的参数生成输入控件。 参考 most PHP frameworks have (or implement the ability from extensions) the functionality you need. e.g. Cakephp has the so-calle ...
  • 使用像这样的静态文件根本不是一个坏主意,但不要打扰存档子目录。 相反,通过一些抽象值将缓存的文件拆分为子目录,如线程id的最后一位或线程id的md5()哈希的前两个字符。 所以你得到: /1/121.html /1/301.html /2/92.html /3/13.html 这将使每个文件的文件保持不变。 您可能希望更多级别,具体取决于您期望拥有的文件的方式: /2/1/121.html /0/1/301.html /9/2/92.html /1/3/13.html 或者,您可能希望将此静态内容放入类 ...
  • 方法1:通过功能输出 可以使用函数编写html而无需构建字符串。 请注意,调用此函数将输出html而不返回它,因此不需要echo DrawComment(blah, blah); ,简单地称之为。 $username, 'text'=>$comment) foreach($comments as $comment) { DrawComment($comment['us ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)