【问题标题】:Why is the table filled with Array[0], Array[1],Array[2],Array[3] after the following SQL statement is executed?为什么执行完下面的SQL语句后,表中会出现Array[0], Array[1],Array[2],Array[3]?
【发布时间】:2009-11-20 06:04:30
【问题描述】:

为什么执行完下面的SQL语句后,表中会出现Array[0]Array[1]Array[2]Array[3]

 mysql_query("INSERT INTO choicetable (announcementid, question, option1, option2, option3, option4) 
   VALUES ('$announcementid', '$choicequestion[$j]', '$option[$j][0]', '$option[$j][1]', '$option[$j][2]', '$option[$j][3]')")
 or die(mysql_error());

当我echo $option[$j][0];时,它显示真实值。但是$option[$j][0]$option[$j][1]$option[$j][2]$option[$j][3]的值不能插入到表中。怎么了?

我正在使用 MySQL。

【问题讨论】:

    标签: php mysql multidimensional-array


    【解决方案1】:

    您需要将数组元素包裹在大括号中,例如,

    "{$option[$j][3]}"
    

    the PHP Manual page for strings;它位于“变量解析”标题下。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-25
      • 1970-01-01
      • 2018-02-13
      相关资源
      最近更新 更多