【问题标题】:how to Insert multi dimensional array in mysql? [duplicate]如何在mysql中插入多维数组? [复制]
【发布时间】:2011-11-25 03:50:28
【问题描述】:

可能重复:
PHP - reformat multidimensional array to insert into MYSQL?

我想做的是在我的数据库中插入多维数组

这是我的代码,但它不起作用,

include 'config/config.php';
    $Currentdatetime = date("Y-m-d h:i:s" ,strtotime("now"));
    $senderID = '530738657,100003201126721,659276806,etc';
    $explode = implode(', ', array_shift($senderID));
    $result = array();
    foreach ($senderID as $row) {
        $result[] = "(" . implode(', ', $row) . ")";
    }
    $query = "INSERT INTO user_invite ($explode) VALUES('$userid','implode (', ', $result)','0','50','$Currentdatetime','0')");

有什么解决办法吗?谢谢

【问题讨论】:

  • 你的 $expolade 应该有数据库表列名。
  • array_shift 在字符串上?大胆的举动! ;)

标签: php mysql


【解决方案1】:

senderID 上的array_shift 是一个错误 senderID 是一个字符串!!!!

在 senderID 上的 foreach 是一个错误!!!!!

替换这个

 $senderID = '530738657,100003201126721,659276806,etc';

     $senderID = explode(',', $senderID   );
    $senderID = '530738657,100003201126721,659276806,etc';

【讨论】:

  • 谢谢,我的代码输入错误,我已经解决了,
猜你喜欢
  • 2011-05-26
  • 1970-01-01
  • 2011-12-12
  • 1970-01-01
  • 1970-01-01
  • 2014-04-29
  • 1970-01-01
  • 2019-08-29
  • 2017-07-03
相关资源
最近更新 更多