Php 不能将标量值用作数组

Php 不能将标量值用作数组,php,arrays,database,wordpress,scalar,Php,Arrays,Database,Wordpress,Scalar,我试图从php访问db wp,这是我用关闭的同一脚本多次执行的操作,但这次我无法使用scalare值作为最新代码行的数组,为什么?我不明白 $dbcnx = @mysql_connect('localhost', 'xxxxxxxxxxxxxxxxx', 'xxxxxxxxxxxxxxxxxxxx'); if (!$dbcnx) { exit('<p>poroppoppopopero ' . 'this is the time of war.</p>');

我试图从php访问db wp,这是我用关闭的同一脚本多次执行的操作,但这次我无法使用scalare值作为最新代码行的数组,为什么?我不明白

$dbcnx = @mysql_connect('localhost', 'xxxxxxxxxxxxxxxxx', 'xxxxxxxxxxxxxxxxxxxx');
if (!$dbcnx) {
  exit('<p>poroppoppopopero ' .
      'this is the time of war.</p>');
}

if (!@mysql_select_db('xxxxxxxxxxxxxxxx')) {
  exit('<p>Unable to locate the joke ' .
      'database at this time pe pe pe pe pe pe pe</p>');
}



$result= @mysql_query ("SELECT  * FROM wp_posts ORDER BY ID DESC LIMIT 0, 30");

    if (!$result){

            exit ('inserimento  non avvenuto'.mysql_error());

    }

    $cont1=1;
    $cont2=1; 
    $cont3=1; 

while ($row=mysql_fetch_array($result)){    


 $id[$cont1]= $row['ID'];
$dbcnx=@mysql\u connect('localhost','xxxxxxxxxxxxxxxxx','xxxxxxxxxxxxxxxxx');
如果(!$dbcnx){
退出(“poroppero”。
“现在是战争时期。”;
}
如果(!@mysql\u选择\u db('xxxxxxxxxxxxxxxxxx')){
退出(“找不到笑话”。
“此时数据库pe

”; } $result=@mysql_query(“选择*从wp_发布按ID描述的订单限制0,30”); 如果(!$result){ 退出('inserimento non-avvenuto'.mysql_error()); } $cont1=1; $cont2=1; $cont3=1; 而($row=mysql\u fetch\u数组($result)){ $id[$cont1]=$row['id'];
是的,你不能使用标量作为数组(比如
$a=5;$a['someKey']
)首先声明
$id
作为数组:
$id=array();
还有,'cont1`等等。这看起来是一种很糟糕的方法。好的,雷米,非常感谢,现在一切都好了