[PHP-DB] foreach problem
Hi, I can't figure out why this won't work: foreach($event_date as $val) { $sql2 = INSERT INTO cal_date_map (entry_id, date) VALUES (\$entry_id\, \$val\); $result = @mysql_query($sql2,$connection) or die (Problem executing foreach database query.); } $event_date is an array with several dates separated by commas. (2003-10-02, 2003-10-03). The code above successfuly inserts the first dae in the array, but none of the others... am I missing something? Thank you. Sam -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] foreach problem
On Friday 07 February 2003 11:22, Sam Folk-Williams wrote: Hi, I can't figure out why this won't work: foreach($event_date as $val) { $sql2 = INSERT INTO cal_date_map (entry_id, date) VALUES (\$entry_id\, \$val\); $result = @mysql_query($sql2,$connection) or die (Problem executing foreach database query.); } $event_date is an array with several dates separated by commas. (2003-10-02, 2003-10-03). The code above successfuly inserts the first dae in the array, but none of the others... am I missing something? Any error messages? If so what does mysql_error() say? -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-db -- /* WHERE CAN THE MATTER BE Oh, dear, where can the matter be When it's converted to energy? There is a slight loss of parity. Johnny's so long at the fair. */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] foreach problem
I don't get any MySQL error... It adds the first entry_id and date exactly as it should... it seems to be acting like entry_date is not an array, but when I use the same foreach loop to echo the contents of entry_date it echoes the multiple values (2003-05-01, 2003-05-02, etc)... I use the same code to insert checkbox data in a different form, so... I'm kinda stumped. Sam Jason Wong [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... On Friday 07 February 2003 11:22, Sam Folk-Williams wrote: Hi, I can't figure out why this won't work: foreach($event_date as $val) { $sql2 = INSERT INTO cal_date_map (entry_id, date) VALUES (\$entry_id\, \$val\); $result = @mysql_query($sql2,$connection) or die (Problem executing foreach database query.); } $event_date is an array with several dates separated by commas. (2003-10-02, 2003-10-03). The code above successfuly inserts the first dae in the array, but none of the others... am I missing something? Any error messages? If so what does mysql_error() say? -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-db -- /* WHERE CAN THE MATTER BE Oh, dear, where can the matter be When it's converted to energy? There is a slight loss of parity. Johnny's so long at the fair. */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] foreach problem
On Saturday 08 February 2003 06:16, Sam Folk-Williams wrote: I don't get any MySQL error... It adds the first entry_id and date exactly as it should... it seems to be acting like entry_date is not an array, but when I use the same foreach loop to echo the contents of entry_date it echoes the multiple values (2003-05-01, 2003-05-02, etc)... I use the same code to insert checkbox data in a different form, so... I'm kinda stumped. $sql2 = INSERT INTO cal_date_map (entry_id, date) VALUES echo $sql2 and plug each of them into the mysql commandline to see what happens. $event_date is an array with several dates separated by commas. (2003-10-02, 2003-10-03). The code above successfuly inserts the first Could you explain what exactly $event_date contains? The output of print_r($event_date) would suffice. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-db -- /* Art is anything you can get away with. -- Marshall McLuhan. */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php