Re: mysql_query problem with multi dim arrays
| From: | Richard Harb | Date: | Mon, 05 Apr 2004 23:47:36 +0000 |
| Subject: | Re: mysql_query problem with multi dim arrays | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-182426@lists.php.net to get a copy of this message | ||
Tuesday, April 6, 2004, 1:21:52 AM, you wrote:
> hi...
> i cant cut and paste my exact mysql query because it takes the ''
> stuff out doubles the $'s and the ,'s in the whole thing (dont know
> why but anyways...)...
> i have a query that goes something like this:
> mysql_query("insert into $GuestbookTable values(NULL,
> '$_SESSION[add][date]', '$_SESSION[add][name]',
> $_SESSION[add][email]..........");
> the problem i get is using the multi dimentional arrays to insert
> text and stuff all i actually get when i echo the query or do a real
> insert is:
> echoed it would be something like:
> insert into rnjresort.guestbook values(NULL, 'array([add]),
> 'array([add])', 'array([add])', .......
> any idea what the problem is here? do i have the '' in the wrong
> places?? i know that works on single dimention arrays but doubled?
Well, then again you can still write your query as:
$sql = "INSERT INTO table (field1, field2, ..., fieldn)"
$sql .= " VALUES ('" . $ar['index1']['index2'][$i] .
"'" .
" ,'" . $ar['index1']['index2'][$i] . "'";
....
or some such ... close/open the strings in between :)
HTH
Richard