草庐IT

insert-image

全部标签

php - mysqli INSERT异常

我有下表:ID:bigintautoincNAME:varchar(255)DESCRIPTION:textENTRYDATE:date我想在表中插入一行。它执行时没有错误,但没有任何内容被插入到数据库中。try{$query="INSERTINTOmytable(NAME,DESCRIPTION,ENTRYDATE)VALUES(?,?,?)";$stmt=$conn->prepare($query);$name='something';$desc='something';$curdate="CURDATE()";$stmt->bind_param("sss",$name,$desc

php - htaccess : redirect an image path to a PHP script

我想要以下图片网址http://www.example.com/image-provider/article/1275449_inline3_scale_700xauto.jpg将被重定向到将实际生成内容的以下PHP脚本http://www.example.com/image-provider?url=article/1275449_inline3_scale_700xauto.jpg我在我的.htaccess中尝试了以下语法RewriteCond%{REQUEST_FILENAME}!-fRewriteRule^/image-provider/(.*)$image-provider?

php - Wordpress: get_attached_media ('image' ) 按标题排序

我想获取特定帖子的所有图片。这适用于:$media=get_attached_media('image');我现在需要的是按标题对这些图像进行排序。我已经可以生成数组中标题的列表:for($i=0;$i我不知道如何按标题排序。谁能帮忙? 最佳答案 获取已经订购的附件而不是订购结果数组会更好,对吧?这将为您节省代码、麻烦和处理。如果您查看WPCodex,get_attached_media()电话get_children(),它调用get_posts()(是的,迅速升级)。在WordPress中,附件(以及几乎任何东西)本质上是一个p

php - 拉维尔 : How to get random image from directory?

我有一个包含子目录的目录,每个子目录中都有图像。我想随机显示图像。在我的php代码下方运行良好,但在Laravel中不起作用,问题出在opendir()和readdir()上。查看Blade';?> 最佳答案 在Laravel中你需要使用Storage使用文件系统。$files=Storage::allFiles($directory);$randomFile=$files[rand(0,count($files)-1)]; 关于php-拉维尔:Howtogetrandomimagefr

php - 多用户应用程序中的 Postgresql 和 PHP : is the currval a efficent way to retrieve the last row inserted id,?

我想知道我用来检索插入到postgresql表中的最后一行的id的方法是否有效..它显然有效,但是当我有许多用户同时在同一个表中添加行时,引用序列currval值可能会出现问题。我的实际做法是:$pgConnection=pg_connect('host=127.0.0.1dbname=testuser=myuserpassword=xxxxx')ordie('cantconnect');$insert=pg_query("INSERTINTOcustomer(name)VALUES('blabla')");$last_id_query=pg_query("SELECTcurrval(

php - 将属性添加到 wp_get_attachment_image

我正在尝试为wp_get_attachment_image的结果添加一个属性.我想使用jquerylazyload来处理我的帖子缩略图的加载,为此我需要添加一个data-original=属性为标签wp_get_attachment_image正在创作。我试过:$imgsrc=wp_get_attachment_image_src(get_post_thumbnail_id($post->ID),"full");$imgsrc=$imgsrc[0];$placeholderimg=wp_get_attachment_image(2897,"full",array('data-origi

PHP GD : The image cannot be displayed because it contains errors

我尝试通过PHPGD创建验证码。但不幸的是我遇到了一个问题!PHP告诉我:Theimage“http://127.0.0.1/par.php”cannotbedisplayedbecauseitcontainserrors.我的代码是这样的 最佳答案 $im=@imagecreatetruecolor(120,20)ordie('CannotInitializenewGDimagestream');你首先隐藏真正的错误并尝试显示一些东西......因为你不去寻找它而无法显示,并公开图像,无论它是否真的生成。然后你继续使用stacko

php - 找不到 Laravel 5 类 'Intervention\Image\ImageServiceProvider'

您好,我对干预图像有疑问。当我使用composerupdate或phpartisanvendor:publish--provider="Intervention\Image\ImageServiceProviderLaravel5"我有错误:[Symfony\Component\Debug\Exception\FatalErrorException]Class'Intervention\Image\ImageServiceProvider'notfound**你有想法吗?我从http://image.intervention.io/getting_started/installatio

php - 如果选择 "image/file"字段的 Laravel 验证?

我有一个“图像”字段,类型是文件,只需要验证是否选择了图像,这意味着它也可以为空。我这样试过:'avatar'=>'mimes:jpeg,jpg,png,gif|max:100000',但它也是必需的。我仍然尝试使用参数present和sometimes但该字段仍然是必需的。如何仅在选择图像时验证它? 最佳答案 如果“avatar”字段可能不存在在您要使用的输入数组中:'avatar'=>'sometimes|mimes:jpeg,jpg,png,gif|max:100000'Insomesituations,youmaywisht

php - 运行 php artisan db :seed more than one and continue for duplicate keys insert

我创建了一个用于在数据库中插入默认值的播种器。如果我多次运行这个播种器,mysql返回重复键错误,所以我的问题是处理此错误的最佳方法是什么?以及如何继续运行其他种子? 最佳答案 您不应该多次运行db:seed命令。更好的方法是重新创建所有表并使用此命令播种数据:phpartisanmigrate:refresh--seed或者在运行phpartisanmigrate:refresh命令后运行一次db:seed。https://laravel.com/docs/5.5/migrations#rolling-back-migration