----- Original Message ----- From: "CDitty" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Saturday, February 01, 2003 11:26 AM Subject: [PHP] MySQL/PHP Associative Array Insert
> A co-worker is teaching me to move to the next level in php. I have > started using associative arrays for my scripts, but I am having a problem > using them to do an insert into MySQL. Can someone give me an example of > how to do an insert to the database using these arrays? My array is > this...$item['itemID'] The trick is to wrap array references in curly braces inside double quoted strings. // some data $array['one'] = 'one'; $array['two'] = 'two'; // build the sql $sql = "INSERT into table (field1,field2) values('{$array['one']}','{array['two']}'"; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php