我面临着奇怪的情况.我在生产环境中遇到错误,而在开发环境中工作正常.
开发:Laravel 5.4.28 PHP 7.0.13 MYSQL 5.7.17
制作:Laravel 5.4.28 PHP 7.2.1 MYSQL 5.7.20
在实现代码中.我用了:
namespace App;
use Illuminate\Support\Facades\Storage;
use Laravel\Scout\Searchable;
use Illuminate\Database\Eloquent\Model;
class Artwork extends Model
{
use Searchable;
Run Code Online (Sandbox Code Playgroud)
在开发中它工作正常.但是在生产中它给了我这个错误:count():参数必须是一个数组或在Builder.php中实现Countable的对象(第936行)
正如你在这张照片中看到的: 在这里输入图像描述 任何想法背后的原因是什么?以及如何解决?
这是这里的代码:
protected function credentials(Request $request)
{
$admin=admin::where('email',$request->email)->first();
if(count($admin))
{
if($admin->status==0){
return ['email'=>'inactive','password'=>'You are not an active person, Please contact to admin'];
}
else{
return ['email'=>$request->email,'password'=>$request->password,'status'=>1];
}
}
return $request->only($this->username(), 'password');
}
Run Code Online (Sandbox Code Playgroud)
当我运行代码时,此错误变为:
“count(): 参数必须是一个数组或一个实现 Countable 的对象”
当我尝试在phpmyadmin中查看wp_posts表时,我看到此错误消息,但不知道它的含义并且以前从未见过它.
有人可以帮助我尝试以某种方式摆脱这个吗?
Warning in ./libraries/sql.lib.php#613
count(): Parameter must be an array or an object that implements Countable
Backtrace
./libraries/sql.lib.php#2128: PMA_isRememberSortingOrder(array)
./libraries/sql.lib.php#2079: PMA_executeQueryAndGetQueryResponse(
array,
boolean true,
string 'afterhours',
string 'wp_posts',
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
string '',
string './themes/original/img/',
NULL,
NULL,
NULL,
string 'SELECT * FROM `wp_posts`',
NULL,
NULL,
)
./sql.php#221: PMA_executeQueryAndSendQueryResponse(
array,
boolean true,
string 'afterhours',
string 'wp_posts',
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
string '',
string './themes/original/img/',
NULL,
NULL,
NULL,
string 'SELECT * FROM `wp_posts`',
NULL,
NULL,
)
Run Code Online (Sandbox Code Playgroud) 我刚刚将PHP版本从5.6升级到7.2.我count()在登录页面中使用了函数,例如:
if(!empty($_POST['username']) && !empty($_POST['password'])):
$records = $conn->prepare('SELECT id,username,password FROM users WHERE username = :username');
$records->bindParam(':username', $_POST['username']);
$records->execute();
$results = $records->fetch(PDO::FETCH_ASSOC);
$message = '';
if(count($results) > 0 && password_verify($_POST['password'], $results['password']) ){
$_SESSION['user_id'] = $results['id'];
header("Location: /");
} else {
$message = 'Sorry, those credentials do not match';
}
endif;
Run Code Online (Sandbox Code Playgroud)
搜索之后,我发现了与此类似的问题和答案,但他们与WordPress有关,他们修改了一些文件,但我找不到使用Pure PHP的解决方案.
我目前收到此错误:
警告:count():参数必须是在 C:\xampp\htdocs\wordpress\wp-includes\theme.php 第 629 行中实现 Countable 的数组或对象
我不知道如何解决它。
我需要最新版本,而不是此处提供的 4.6.6 。我阅读了手册和其他线程,但一切都指向这个旧版本。我需要最新版本的原因是旧版本在 PHP 7.2 上不能很好地工作,如此处所述。
是否可以通过从此处下载最新版本来“手动”进行安装/升级?存档的内容看起来与我从“phpMyAdmin PPA”中获得的内容类似。我不能手动覆盖文件系统中的一些文件来将我的版本升级到最新版本吗?如果我在 Ubuntu 下解压了存档,是否有启动安装的命令?