// +++ new line to code in line 507 $data[] = $table; // first elemeint in data array is the table name foreach ($obj_def['columns'] as $column => $attrib) { $column_names[] = $column; $placeholder = isset($attrib['data type']) ? $col_type_map[$attrib['data type']] : "'%s'"; $column_placeholders[] = $placeholder; $column_assignments[] = $column .' = '. $placeholder; $data[] = $obj->$column; } $data[] = $obj->$id_name; if ($obj->is_new) { // --- change this line: db_query("INSERT INTO {$table} (". implode(', ', $column_names) .", $id_name) VALUES (". implode(', ', $column_placeholders) .', %d)', $data); // +++ to this line db_query("INSERT INTO {%s} (". implode(', ', $column_names) .", $id_name) VALUES (". implode(', ', $column_placeholders) .', %d)', $data); } else { // --- change this line: db_query("UPDATE {$table} SET ". implode(', ', $column_assignments) ." WHERE $id_name = %d", $data); // +++ to this line db_query("UPDATE {%s} SET ". implode(', ', $column_assignments) ." WHERE $id_name = %d", $data); }