Jump to content

Help with OOP code


themistral

Recommended Posts

Hiya,

 

I don't have a great understanding of OOP code so would really appreciate your help!

 

I have this:

 

	if (is_array($fields)) {
		$sql = "select ".implode(",",$fields)." from ".TABLE_PREFIX.$form['table']." where ".$primary_key." = '".$$primary_key."'";
		//echo ($show_select_sql) ? $sql : "";
		$uniform_result = mysql_query($sql,$databaseLink);
		$uniform_record = mysql_fetch_object($uniform_result);
		print_r($uniform_record);
	}

	foreach ($form['element'] as $element) { 
		if ($element['xref'] != "") {
			if ($_POST[$element['form_name']] == "") { 
				$sql = "select ".$element['xref']['column']." from ".TABLE_PREFIX.$element['xref']['table']." where ".$form['primary_key']." = '".$$form['primary_key']."'";
				$xref_result = mysql_query($sql,$databaseLink);
				while ($xref_record = mysql_fetch_object($xref_result)) {
					$values[] = $xref_record->$element['xref']['column'];
				}
				$$element['form_name'] = $values;
			} else {
				$$element['form_name'] = $_POST[$element['form_name']];
			}
		} elseif ($element['concatenation_callback'] != "") {
			if ($_POST[$element['form_name']] != "") {
				$$element['form_name'] = $_POST[$element['form_name']];
			} else {
				$$element['form_name'] = $element['concatenation_callback']($uniform_record->$element['db_name']);
			}
		} else { 
			if ($element['type'] == "date") {
				$$element['form_name'] = ($_POST[$element['form_name']."_day"] != "") ? $_POST[$element['form_name']."_year"]."-".$_POST[$element['form_name']."_month"]."-".$_POST[$element['form_name']."_day"] : $uniform_record->$element['db_name'];
			} else {
				$$element['form_name'] = ($_POST[$element['form_name']] != "") ? $_POST[$element['form_name']] : $uniform_record->$element['db_name'];

			}
		}
		uni_output_filter($element);
	}

 

This line just before the end breaks the code resulting in a white page.

$$element['form_name'] = ($_POST[$element['form_name']] != "") ? $_POST[$element['form_name']] : $uniform_record->$element['db_name'];

 

If I remove $uniform_record->$element['db_name'] and replace it with "test" the page renders correctly.

 

This is basically an edit form and the $uniform_record->$element['db_name'] should be populating the relevant fields with existing data.

 

Happy to provide more info if required!

 

Thanks in advance!

Link to comment
https://forums.phpfreaks.com/topic/243194-help-with-oop-code/
Share on other sites

Ok I have LOTS of undefined variable notices...but they wouldn't result in a blank page would they?

 

I should also point out that the script worked perfectly before the site was moved to a new server running PHP5 - the old server would likely still have been running PHP4...nothing in the script has been changed, so likely outdated code or different server settings I guess.

Link to comment
https://forums.phpfreaks.com/topic/243194-help-with-oop-code/#findComment-1249067
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.