Question
OT: A PHP Punt! Inserting arrays into data tables....
OK - I've beat my head to a pulp.
I have an array of paired strings. I want to add the whole array to a data
table, in alternating fields.
I have this -
mysql_select_db($database_cmaConn, $cmaConn);
$fields = "'keyJargon','keyDef'";
$values = "'".implode(array_values($toAdd), "','")."'";
function mysql_insert($table,$ToAdd) {
$q = 'INSERT INTO `'.$table.'` ('.$fields.') VALUES ('.$values.')';
$res = mysql_query($q)OR die(mysql_error());
return true;
} //end function
if (isset($_POST['Submit'])) {
$jargonArray=explode("\n",$_POST['upload']);
// this splits the input data into consecutive elements of the array, one
for each new line.
$i=0;
foreach($jargonArray as $key => $value) {
if (strlen($value) > 0) {
$jargon[] = explode("\x09",$value);
//this splits the tab-delimited input data into adjacent array elements.
mysql_insert('cma_keywords',$jargon[$i][0][1]);
$i++;
} // endif
}
But it's broke. What am I doing wrong?
--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================
I have an array of paired strings. I want to add the whole array to a data
table, in alternating fields.
I have this -
mysql_select_db($database_cmaConn, $cmaConn);
$fields = "'keyJargon','keyDef'";
$values = "'".implode(array_values($toAdd), "','")."'";
function mysql_insert($table,$ToAdd) {
$q = 'INSERT INTO `'.$table.'` ('.$fields.') VALUES ('.$values.')';
$res = mysql_query($q)OR die(mysql_error());
return true;
} //end function
if (isset($_POST['Submit'])) {
$jargonArray=explode("\n",$_POST['upload']);
// this splits the input data into consecutive elements of the array, one
for each new line.
$i=0;
foreach($jargonArray as $key => $value) {
if (strlen($value) > 0) {
$jargon[] = explode("\x09",$value);
//this splits the tab-delimited input data into adjacent array elements.
mysql_insert('cma_keywords',$jargon[$i][0][1]);
$i++;
} // endif
}
But it's broke. What am I doing wrong?
--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================
