Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 警告:内爆():在mysql中传递的参数无效_Php_Mysql_Sql - Fatal编程技术网

Php 警告:内爆():在mysql中传递的参数无效

Php 警告:内爆():在mysql中传递的参数无效,php,mysql,sql,Php,Mysql,Sql,这是我的代码。传递参数时出错,此内爆函数正确吗? 我正在使用插入查询进行分解函数尝试更新代码 <?php include_once("config.php"); $result=mysqli_query($mysqli,"SELECT * FROM image,tags WHERE image_id=fk_image_id ORDER BY creation_dt DESC LIMIT 5 "); while($res = mysqli_fetch

这是我的代码。传递参数时出错,此内爆函数正确吗? 我正在使用插入查询进行分解函数

尝试更新代码

<?php        
    include_once("config.php");
    $result=mysqli_query($mysqli,"SELECT * FROM image,tags WHERE image_id=fk_image_id  ORDER BY creation_dt DESC LIMIT 5 ");
    while($res = mysqli_fetch_array($result)) {
        $tagname=$res['tag_txt'];
        $cols = implode(',','array_keys($tagname)');
        echo $cols;
        echo "<tr>"."<img  src='http://localhost:8080/memes/".$res['path_txt']."' width='380' height='280' style='padding: 10px;'  />"."</tr>";            
    }        
?> 
include_once(“config.php”);
$result=mysqli_query($mysqli,“选择路径_txt,组_CONCAT(标记_txt分隔符','))作为来自图像的图像_标记,其中图像_id=fk_图像_id按路径分组_txt按创建顺序_dt DESC LIMIT 5”);
而($res=mysqli\u fetch\u数组($result))
{
$tagname=$res['image_tag'];
echo$标记名;
回声“.”;
}//while循环结束

删除第二个参数周围的单引号很好,但是字符串是单独显示的!!!我希望将外键字符串显示为单个字符串。在代码中,您传递的是字符串而不是数组内爆函数,需要数组作为第二个参数,单引号或双引号在字符串中显示结果。所以你必须通过数组而不是字符串来内爆函数,参考这个解释,它很好,但是字符串是分开显示的!!!我想将外键字符串显示为一个字符串。在声明$i=0时,请先执行此操作;在while循环中,您提到了$tagname=$res['tag_txt'];这是一个单一的字符串值,所以你必须把它看作数组,就像这个$TAGNOTE[$i]=$RES[TAGIGTXT ];并增加$i++;while循环结束后$cols=内爆(“,”,$tagname)@sunilwananje编辑您的答案,并添加您作为评论添加的要点。这会让你的答案更有意义。sunilwananje请粘贴你的代码并正确定义。
    include_once("config.php");
    $result=mysqli_query($mysqli,"SELECT path_txt,GROUP_CONCAT(tag_txt SEPARATOR ', ') as image_tag FROM image,tags WHERE image_id=fk_image_id GROUP BY path_txt ORDER BY creation_dt DESC LIMIT 5");

    while($res = mysqli_fetch_array($result)) 
    {
        $tagname = $res['image_tag'];
        echo $tagname;
        echo "<tr>"."<img  src='http://localhost:8080/memes/".$res['path_txt']."' width='380' height='280' style='padding: 10px;'  />"."</tr>";
    }//end of while loop
implode — Join array elements with a string

array_keys — Return all the keys or a subset of the keys of an array

Example :

$array = array("1" => "PHP code tester",  
              "foo" => "bar",
               5 => 89009, 
              "case" => "Random Stuff",
              "PHP Version" => phpversion()
              );

$arrayKey = implode(',',array_keys($array));

echo $arrayKey;

output will be : 1,foo,5,case,PHP Version

But you give a string parameter in this line

$cols = implode(',','array_keys($tagname)');

So you get warning : implode(): Invalid arguments passed in

actually this line will be :

$cols = implode(',',array_keys($tagname));