Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/58.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_fetch_assoc()不显示任何内容_Php_Mysql_Rows - Fatal编程技术网

Php Mysql_fetch_assoc()不显示任何内容

Php Mysql_fetch_assoc()不显示任何内容,php,mysql,rows,Php,Mysql,Rows,这次我遇到了mysql_fetch_assoc的问题,使用后我在屏幕上看不到任何东西。它应该在屏幕上打印一堆记录,相反,我只有一个withe屏幕 下面是我的代码: $selected="SELECT name,namep,price,time FROM img INNER JOIN products on img.id_img=products.id_img WHERE img.id_img='$rand_n'"; $selected =

这次我遇到了mysql_fetch_assoc的问题,使用后我在屏幕上看不到任何东西。它应该在屏幕上打印一堆记录,相反,我只有一个withe屏幕

下面是我的代码:

$selected="SELECT name,namep,price,time
         FROM img
         INNER JOIN products on img.id_img=products.id_img
         WHERE img.id_img='$rand_n'";
  $selected = mysql_query($selected)
        or die ("Impossible execute the query SEL"). mysql_error();
  //____________________________________________________________________
    while($row=mysql_fetch_assoc($selected))
        {
            if(isset($row) && !empty($row))
                {
                    printf("Product name: &nbsp %s", $row['namep']);
                echo '<br />';
                echo "Price: &nbsp"; echo $row['price'];
                echo '<br />';
                echo "Data: &nbsp"; echo $row['time'];
                echo '<br />';
                echo "Immage: <img src='".$row['name']."' alt='Image'>";
                echo '<hr> <br />';

                $value--;
            }
            else
            {
                echo "Yep, qualcosa decisamente non va!";
            }
        }
有人能很好地解释为什么它不起作用?非常感谢。

试试这个

$selected="SELECT ........";
$selected2 = mysql_query($selected)
    or die ("Impossible execute the query SEL"). mysql_error();
if(mysql_num_rows($selected2) > 0){
    while($row=mysql_fetch_assoc($selected2))
     {

       printf("Product name: &nbsp %s", $row['namep']);
            echo '<br />';
            echo "Price: &nbsp"; echo $row['price'];
            echo '<br />';
            echo "Data: &nbsp"; echo $row['time'];
            echo '<br />';
            echo "Immage: <img src='".$row['name']."' alt='Image'>";
            echo '<hr> <br />';
        }
}
else
        {
            echo "Yep, qualcosa decisamente non va!";
        }

$rand\u n的值是多少?在文件error\u reportingE\u ALL的开头打开error reporting;我认为这句话不正确:不可能执行查询SEL。mysql\u错误应该是这样的:执行查询SEL。错误;