0

Possible Duplicate:
PHP - reformat multidimensional array to insert into MYSQL?

what I want to do is insert multi dimensional array in my database

here is my code,but it not working,

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')");

any solution? thanks

2
  • Your $expolade should have database table coloumn names. Commented Nov 25, 2011 at 3:58
  • 1
    array_shift on a string? Bold move! ;) Commented Nov 25, 2011 at 4:11

1 Answer 1

1

array_shift on senderID is an error senderID is a string!!!!

foreach on senderID is an error !!!!!

replace this

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

with

     $senderID = explode(',', $senderID   );
    $senderID = '530738657,100003201126721,659276806,etc';
Sign up to request clarification or add additional context in comments.

1 Comment

thanks, I type wrong in my code and i solved it already,

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.