Background...
I inherited a nightmare. A backend php interface that was originally dev'd on a linux box . Told the site was migrating to a windows box w/ php 5. Redeveloped site on a widows box w/ php 5 ONLY to be informed that the site will now actually live on a linux box w/ php 4.3.2 .
Heres the prob
Most everything works now..
Except in passing an array as a form variable to a function that updates the database. Works on windows php 5 ... chokes on Linux PHP 4.3.2
here is the call to the function
<? // Aktionen des Editors
if ($action=='save') {
SaveRecord($Formfield, $Tablename); ?>
here is the function it is choking on. I bolded the choke points
function SaveRecord($Formfields, $Table) {
global $Fields;
reset($Fields);
if (is_array($Formfields[$Table])) {
$SQL_UPDATE = "UPDATE $Table SET ";
foreach($Fields as $Field) {
if (isset($Field['type']) && isset($Field['field'])) {
$Fieldtype = $Field['type'];
$Fieldname = $Field['field'];
if (!isset($Field['external']) || $Field['external'] != 'true' && array_key_exists($Fieldname, $Formfields[$Table])) {
$SQL_UPDATE .= " $Fieldname='" . str_ireplace("'", "''", $Formfields[$Table][$Fieldname]) . "', ";
}
}
}
$SQL_UPDATE = StripRight($SQL_UPDATE, ',');
$SQL_UPDATE .= " WHERE id=".$Formfields[$Table]['id'];
mysql_query($SQL_UPDATE) or die(mysql_error());
//return mysql_affected_rows();
}
//if (is_array($Formfields)) { echo'isarray';}else{echo 'notarray';}
// Appendixfelder speichern
reset($Formfields);
foreach($Formfields as $Source => $Tablefields) {
if (stripos($Source, '@') !== false) {
$AppendixSource = explode('@', $Source);
$AppendixTable = $AppendixSource[1];
} else {
$AppendixSource = $Source;
$AppendixTable = $Source;
}
$SQL_UPDATE = "\nUPDATE $AppendixTable SET ";
if (sizeof($AppendixSource) == 2) {
foreach($Tablefields as $Formfield => $Formvalue) {
if ($Formfield == 'id') {
$Index = $Formvalue;
} else {
$SQL_UPDATE.= "$Formfield='$Formvalue',";
}
}
$SQL_UPDATE = StripRight($SQL_UPDATE, ',');
$SQL_UPDATE.= "WHERE id=$Index";
mysql_query($SQL_UPDATE) or die(mysql_error());
//echo "\n$Update";
// echo "\n$AppendixSource[0] - $AppendixSource[1] - $Formfield[field]";
}
}
}
the prob is $formfields is not being recognized as an array on the linux 4.3.2
box
any clues would be greatly appreciated
thanks