我正在建立一个网站,用户可以使用PHP和mySQL数据库存储代码片段.但我无法弄清楚如何安全地将用户输入的代码插入我的数据库.我无法使用我通常使用的"安全"功能(trim,stripslashes等)来转换输入,因为重点是您可以查看在数据库中输入的代码.我看了my_real_escape_string(),但我看到,它并没有逃脱%和_,这可以作为MySQL的通配符.这会构成威胁,还是我可以使用my_real_escape_string?Thanx提前.
我正在尝试从我的表中获取本周的数据
我有以下代码,它给了我 31 天的数据(一个月,但它是分开的,这是我需要的)
$stats["tmv"] = "";
$stats["tmd"] = "";
$stats["tru"] = array();
for ($i=1; $i <= 31; $i++) {
$stats["tmv"] .= DB::table('stats')->select(DB::raw('*'))->where(DB::raw('DAY(created_at)'), '=', $i)->where('stats_type', "mv")->count();
$stats["tmd"] .= DB::table('stats')->select(DB::raw('*'))->where(DB::raw('DAY(created_at)'), '=', $i)->where('stats_type', "md")->count();
$stats["tru"][$i] = DB::table('users')->select(DB::raw('*'))->where(DB::raw('DAY(created_at)'), '=', $i)->count();
if ($i != 31) {
$stats["tmv"] .= ",";
$stats["tmd"] .= ",";
}
}
Run Code Online (Sandbox Code Playgroud)
输出:
"tmv" => "11,4,1,13,0,5,15,2,0,24,1,7,17,18,45,14,31,61,3,1,4,1,1,27,30,47,18,60,10,0,156"
Run Code Online (Sandbox Code Playgroud)
如何编辑我的查询以选择本周的数据,但仍输出如下计数:
"11,4,1,13,0,5,15"
Run Code Online (Sandbox Code Playgroud) 要涵盖的问题:
如何在搜索框/表单
中添加图标 如何在输入字段中添加图标
我遇到了以下问题,我无法让 FontAwesome fa-search 图标位于输入字段/搜索框的右侧。
这是表单的图像:
网站标题上的 HTML 搜索表单
链接到这里的表格(不是常青树):https :
//www.themirrorman.co
这是我的原始代码:
@media screen and (min-width: 800px) {
#header-search-desktop-div {
position: absolute;
left: 180px;
width: 450px;
margin-top: 0;
margin-bottom: 0;
border: 1px solid #881d98;
border-radius: 24px;
}
#header-search-desktop-div #header-search-fa {
position: absolute;
color: #7E7E7E;
z-index: 100;
font-size: 27px;
}
#header-search-desktop-div .fa-search {
top: 5%;
left: 1.5%;
line-height: 0.8em;
}
}Run Code Online (Sandbox Code Playgroud)
<div id="header-search-desktop-div">
<form role="search" method="get" class="searchform" action="https://themirrorman.co/">
<span id="header-search-fa" class="fa fa-search">
<input id="header-search-desktop-input" name="product-search" type="text" …Run Code Online (Sandbox Code Playgroud)我刚刚将VS代码升级到v1.20.1现在,我到处都有错误告诉我用单引号替换双引号.
首先,我正在考虑禁用此功能,因为我是一个双引号的人.我已经检查了我的用户设置(文件 - >首选项 - >设置),并搜索tslint了与引号有关但无法找到的任何验证.
其次,我认为在JS中使用单引号可能是一种好习惯,我应该习惯它.
我怀疑这可能是一种好习惯,如果不是,请证明我错了.
我的问题是:
在JS中使用单引号的后续功能中是或将会被视为良好做法?
如何在VS Code中禁用双引号验证?
我正在自己的网站上工作localhost,突然我发现了这个错误。
我在Firefox上收到此错误
<script> source URI is not allowed in this document
Run Code Online (Sandbox Code Playgroud)
chrome上没有任何内容,但是如果我尝试使用文件代码,则会得到:
Application Error: There was a problem getting data for the application you requested. The application may not be valid, or there may be a temporary glitch. Please try again later.
Run Code Online (Sandbox Code Playgroud)
它基本上用于:https : //connect.facebook.net/en_US/sdk.js。
浏览器甚至没有发送该文件的GET请求。
以前一切都可以完美工作。不知道为什么我要得到这个。
我正在尝试运行命令,chown -R apache:apache xyz但是我收到错误,chown: apache:apache': invalid user
然后我尝试了用户www-data,但结果相同.
然后我尝试通过运行来检查谁拥有apache进程ps -Af |grep httpd.我得到以下,
root 29577 1 0 18:00 ? 00:00:00 /opt/lampp/bin/httpd -k start -DSSL -DPHP5
nobody 29754 29577 0 18:00 ? 00:00:00 /opt/lampp/bin/httpd -k start -DSSL -DPHP5
nobody 29756 29577 0 18:00 ? 00:00:00 /opt/lampp/bin/httpd -k start -DSSL -DPHP5
nobody 29757 29577 0 18:00 ? 00:00:00 /opt/lampp/bin/httpd -k start -DSSL -DPHP5
nobody 29758 29577 0 18:00 ? 00:00:00 /opt/lampp/bin/httpd -k start -DSSL -DPHP5
nobody 29759 29577 0 18:00 ? …Run Code Online (Sandbox Code Playgroud) 我有一个带有 ElasticSearch 的自动完成 jquery 功能。输入第一个字母时出现以下错误。
跨域请求被阻止:同源策略不允许读取位于http://localhost:9200/test12/test3/_search?pretty的远程资源。(原因:缺少 CORS 标头“Access-Control-Allow-Origin”)。
这是代码
$(function () {
$("#keyword").autocomplete({
source: function (request, response) {
$.ajax({
url: "http://localhost:9200/test12/test3/_search?pretty",
data: "q=firstname:" + request.term +"*" ,
dataType: "json",
type: "POST",
headers: {
'Access-Control-Allow-Origin': 'http://localhost'
},
crossDomain: true,
jsonpCallback:"callback",
contentType: "application/json; charset=utf-8",
success: function (data) {
console.log(data);
response($.map(data.d, function (item) {
return {
label: item.split('-')[0],
val: item.split('-')[1]
}
}))
},
error: function (response) {
alert('error'+ response.responseText);
},
failure: function (response) {
alert('failure'+response.responseText);
}
});
},
select: …Run Code Online (Sandbox Code Playgroud) 假设我有一个组件,我想要应用一些边距,最好通过Bootstrap辅助类,例如mt-3来应用上边距.当我在组件上指定它们时,如下所示:
<my-custom-input
required
class="mt-3"
name="usr"
label="User"
placeholder="Please enter username"
[(ngModel)]="username">
</my-custom-input>
Run Code Online (Sandbox Code Playgroud)
在class="mt-3"没有做任何事情!通过Chrome开发工具手动设置边距也是不可能的...我猜是因为my-custom-input不是预定义的HTML元素(如div),它不能定义边距?
在任何应用程序中,这似乎都是非常微不足道的事情,但我很惊讶到目前为止我找不到答案.我们如何重新定位这样的组件?至少,在父级别(而不是在组件模板内)指定边距似乎是至关重要的事情吗?
我真的不知道为什么,但是当我从Angular 4 => 5升级时,ng serve似乎没有工作并且抛出错误:
_this.host.getOutputName中的错误不是函数
webpack:编译失败.
这是我的包的样子:
{
"name": "website",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^5.0.0",
"@angular/common": "^5.0.0",
"@angular/compiler": "^5.0.0",
"@angular/core": "^5.0.0",
"@angular/forms": "^5.0.0",
"@angular/http": "^5.0.0",
"@angular/platform-browser": "^5.0.0",
"@angular/platform-browser-dynamic": "^5.0.0",
"@angular/router": "^5.0.0",
"@ng-bootstrap/ng-bootstrap": "^1.0.0",
"core-js": "^2.4.1",
"jquery": "^3.2.1",
"ngx-textarea-autosize": "^1.1.1",
"rxjs": "^5.1.0",
"zone.js": "^0.8.4"
},
"devDependencies": {
"@angular/cli": "1.2.0",
"@angular/compiler-cli": "^4.0.0",
"@angular/language-service": "^4.0.0", …Run Code Online (Sandbox Code Playgroud) 我在用
var foo = function(){}
Run Code Online (Sandbox Code Playgroud)
typeof(foo) - 返回函数而不是Object
而javascript概念告诉javascript中的所有函数都是对象?