我正在从数据库内的所有行创建一个大字符串.
这工作正常,但是我在使用字符串作为数组时遇到问题,因为每个数据库行的结尾都不以逗号结尾,所以我得到了最后一个和第一个单词之间的连接.
我怎么能改变这个:
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
// concatenate all the tags into one string
$tags .= $row['tags'];
}
Run Code Online (Sandbox Code Playgroud)
所以$ row ['tags']中的每一个都有逗号后面的逗号?
希望这是有道理的.
我正在使用 imagecreatefromstring 并当前验证正确的图像文件格式。
所以一个链接:
swqkdwfibqwfwf
Run Code Online (Sandbox Code Playgroud)
不起作用,因为它不是有效的文件类型。但我刚刚发现了这一点:
sibdlsibiwbifw.png
Run Code Online (Sandbox Code Playgroud)
将在我的验证中没有错误地发送。对于不返回图像的图像链接,我收到此错误:
Warning: file_get_contents(etwteet.png): failed to open stream: No such file or directory in /var/www/clients/client2/web3/web/process/addnewbuild.php on line 141
Warning: imagecreatefromstring(): Empty string or invalid image in /var/www/clients/client2/web3/web/process/addnewbuild.php on line 141
Warning: imagejpeg() expects parameter 1 to be resource, boolean given in /var/www/clients/client2/web3/web/process/addnewbuild.php on line 143
Run Code Online (Sandbox Code Playgroud)
有没有办法可以捕获此错误,以便我可以停止代码处理并通知用户?
用于获取 URL 的代码:
$imagefile = image url;
$resource = imagecreatefromstring(file_get_contents($imagefile));
Run Code Online (Sandbox Code Playgroud)
谢谢。克雷格.
我试图在给定 URL 时检测图像是否为图像。要从 url 保存图像,我使用了以下内容:
// create the image and save it
$imagefile = $URL;
$resource = imagecreatefromstring(file_get_contents($imagefile));
// X amount of quality is the last number
imagejpeg($resource, "images/covers/$imagepath.jpeg", 50);
imagedestroy($resource);
Run Code Online (Sandbox Code Playgroud)
$URL 只是用户提供的图片链接。
我尝试了以下方法:
$imagefile = $addBuildCover;
$resource = imagecreatefromstring(file_get_contents($imagefile));
if ($resource !== false) {
$return['imageGood'] = true;
} else {
$return['imageBad'] = true;
}
Run Code Online (Sandbox Code Playgroud)
我已经尝试过该代码,并且返回了“imageBad”的正确 JSON 返回值,但在此之前它给了我一个错误:
Warning: file_get_contents(ewffw.png): failed to open stream: No such file or directory in /var/www/clients/client2/web3/web/process/addnewbuild.php on line 116
Warning: imagecreatefromstring(): Empty string or invalid …Run Code Online (Sandbox Code Playgroud) 关于如何使用 javascript/jQuery 滚动到 ckeditor 编辑器底部的任何想法?
我找不到任何东西。
我所有的搜索显示是:
document.getElementById("ID").contentWindow.scrollTo(0,3);
Run Code Online (Sandbox Code Playgroud)
这给了我一个 contentWindow 未定义的错误。
ckeditor 文本部分的类似乎是“cke_editable”。
滚动到编辑器底部有什么帮助吗?
无法找到任何相关内容,但我确信它很简单.
当我使用url更改查询时,我有一个需要复制4次的路由.
目前:
Route::get('/', function()
{
$builds = Blog::findBuilds();
return View::make('pages/home', compact('builds'));
});
Run Code Online (Sandbox Code Playgroud)
我想做的是例如:
Route::get(array('/', '/trending', 'staff-picks'), function()
{
$builds = Blog::findBuilds();
return View::make('pages/home', compact('builds'));
});
Run Code Online (Sandbox Code Playgroud)
但那当然不行.什么诀窍?
使用一个按钮页面,用按钮的值填充textarea.
这适用于作为按钮的项目,但无法使其适用于列表项.
我必须使用列表项,因为有些按钮有下拉列表.
jsfiddle显示列表项警告0甚至认为它确实有值.
<li class='item_value' value='value'>
<a href='#'>Click</a>
</li>
<br><br>
<button type='button' class='btn btn-success item_value' value='value2'>Click 2</button>
Run Code Online (Sandbox Code Playgroud)
jQuery的:
$(".item_value").on('click',function(){
alert(this.value);
});
Run Code Online (Sandbox Code Playgroud) 试图不使用jQuery脚本进行砌体效果,因此寻找CSS替代品.
我正在尝试使用列计数,这似乎有效,但不是预期的.
所以列就在那里,但有时容器中的项目被分割为多个,正如您在本示例中应该看到的那样:
http://jsfiddle.net/DTcHh/3858/
#builds {
width: 100%;
}
.cols {
-moz-column-count:4;
-moz-column-gap: 3%;
-moz-column-width: 25%;
-webkit-column-count:4;
-webkit-column-gap: 3%;
-webkit-column-width: 25%;
column-count: 4;
column-gap: 3%;
column-width: 25%;
}
.item {
height: auto;
width: 100%;
}
Run Code Online (Sandbox Code Playgroud)
我正在使用数据库中的项目分页,有时一切正常,但有些则没有.
任何逻辑,为什么/我做错了什么?
我正在使用Dropzone和Laravel.目前,图像正在上传到S3.
但我需要知道一种方法,我可以知道文件上传完成后,还可以获取他们的网址.
目前这个:(使用文档)
var token = "{!! csrf_token() !!}";
$("div#dropzoneFileUpload").dropzone({
url: "/project/uploadImage",
params: {
_token: token
}
});
Dropzone.options.dropzoneFileUpload = {
paramName: "file", // The name that will be used to transfer the file
maxFilesize: 2, // MB
accept: function(file, done) {
},
init: function() {
this.on("addedfile", function(file) {
alert("Added file.");
});
}
};
Run Code Online (Sandbox Code Playgroud)
添加文件时不会发出任何警报,事件似乎没有任何效果.
任何帮助?
作为参考,这是我创建的div:
<div class='dropzone' id='dropzoneFileUpload'></div>
Run Code Online (Sandbox Code Playgroud) 而不是做:
$cars = $mysqli->query("SELECT * FROM cars");
$count = $cars->num_rows();
if ($count) {
// is rows
}
Run Code Online (Sandbox Code Playgroud)
我不想选择所有行或单列,我只想要计数。
在我脑海中:
$cars = $mysqli->query("SELECT COUNT(*) as count FROM cars");
Run Code Online (Sandbox Code Playgroud)
但是,我如何使用该计数值?我需要对其运行 if 语句。
正在为所有未来项目开发基本模板,并决定使用 Laravel。
目的只是为我将来制作的任何网站(基本博客、管理区域+用户登录系统)创建一个起点。
我按照有关 CRUD 基础知识的教程制作了一个简单的博客管理应用程序。不过我希望将其放入 /admin 区域。
之前,我的路线中有这样的:
Route::resource('blog', 'BlogController');
Run Code Online (Sandbox Code Playgroud)
这样我就可以简单地在domain.com/blog URL 上使用我的BlogController 中的功能。
这一切都有效,但我想将其隐藏在管理区域后面。我想我可以将包含所有博客视图的博客文件夹移动到管理文件夹中,但会出现“路线未定义”错误。
视图文件夹是:
- Views
- admin
- blog
- edit.blade.php
- index.blade.php
- new.blade.php
- show.blade.php
- home.blade.php
Run Code Online (Sandbox Code Playgroud)
以前,我的博客文件夹只是位于视图文件夹本身中。我需要更改什么才能使domain.com/admin/blog 与以前一样工作?
使用 Laravel 4.2