Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/66.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 什么';这个密码怎么了? $child=array(); $i=0; 而($row=mysql\u fetch\u array($result,mysql\u ASSOC)) { $child[i]=$row['userId']; $i++; } $i=0; 而($i_Php_Mysql - Fatal编程技术网

Php 什么';这个密码怎么了? $child=array(); $i=0; 而($row=mysql\u fetch\u array($result,mysql\u ASSOC)) { $child[i]=$row['userId']; $i++; } $i=0; 而($i

Php 什么';这个密码怎么了? $child=array(); $i=0; 而($row=mysql\u fetch\u array($result,mysql\u ASSOC)) { $child[i]=$row['userId']; $i++; } $i=0; 而($i,php,mysql,Php,Mysql,您正在使用i作为数组索引,而不是$i: $child= array(); $i = 0; while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $child[i] = $row['userId']; $i++; } $i = 0; while($i<=5) { echo $child[i]; $i++; } 这应该是$child[$i]。因为$child[i]中的i被解释为一个常量(常量i的值

您正在使用
i
作为数组索引,而不是
$i

$child= array();
$i = 0;

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
    $child[i] = $row['userId'];
    $i++;
} 

$i = 0;
while($i<=5)
{
    echo $child[i];
    $i++;
}

这应该是
$child[$i]
。因为
$child[i]
中的
i
被解释为一个常量(常量
i
的值被用作索引)或者如果没有字符串这样的常量。您可以使用获取变量/值转储。

您忘记了$child[i]中的$i……应该是$child[$i];)

$code>$child=array(); $i=0; 而($row=mysql\u fetch\u array($result,mysql\u ASSOC)) { $child[$i]=$row['userId']; $i++; } $i=0;
而($i如果你想要数字索引,你可以不用$i.试试

$child= array();
$i = 0;

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
    $child[$i] = $row['userId'];
    $i++;
} 

 $i = 0;
while($i<=5)
{
    echo $child[$i];
    $i++;
}
while($row=mysql\u fetch\u数组($result,mysql\u ASSOC))
{
$child[]=$row['userId'];
} 

对于($i=0;$i,$result中的查询是什么?+1。在“第一个正确答案获得投票权”的好ole时代发生了什么。我不知道那些日子发生了什么,我没有投票给自己。也许人们喜欢结尾的笑脸,我自己认为这个答案的格式更好(并且在我之前1分钟发布)所以应该是最重要的。还有另一个你应该用E_NOTICE错误级别集测试的原因。。。
$child= array();
$i = 0;

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
    $child[$i] = $row['userId'];
    $i++;
} 

 $i = 0;
while($i<=5)
{
    echo $child[$i];
    $i++;
}
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
    $child[] = $row['userId'];
} 

for($i=0;$i<5;$i++)
{    
echo $child[$i].' <br />;
}