Jump to content

Undefined Variable


fakierock

Recommended Posts

Hi guys,

I have a CMS system which I've spent the last week fixing. It's built in PHP, and now I'm stuck on the most simplest of tasks. I can't figure out why I am receiving an "undefined variable" error within this block of code. Any help would be greatly appreciated.

 

 

 

function track_app($app_id, $lang_code, $str, $instance) {
 
$lang_id = get_lang_id($lang_code);
 
if ($instance > 0) {
 
if ($str == 'LOAD_APP' || $str == 'APP_LOADED') {
 
$query = "INSERT INTO `tracking` (
`APPLICATION_ID`, `LANG_ID`, `INFO`, INSTANCE_ID
) VALUES (
$app_id,  $lang_id, '$str', $instance
)";
 
 
mysql_query("INSERT INTO `tracking_backup` (
`APPLICATION_ID`, `LANG_ID`, `INFO`, INSTANCE_ID
) VALUES (
$app_id,  $lang_id, '$str', $instance
)");
 
mysql_query("UPDATE `instances` SET ACTIVE = 1 WHERE INSTANCE_ID = $instance");
 
} else {
$query = "INSERT INTO `tracking` (
`APPLICATION_ID`, `LANG_ID`, `INFO`
) VALUES (
$app_id,  $lang_id, '$str'
)";
}
 
mysql_query($query);
 
}
Link to comment
https://forums.phpfreaks.com/topic/281640-undefined-variable/
Share on other sites

Try this logic tweak...

function track_app($app_id, $lang_code, $str, $instance) {

	$lang_id = get_lang_id($lang_code);

	$query = "INSERT INTO `tracking` (
	`APPLICATION_ID`, `LANG_ID`, `INFO`
	) VALUES (
	$app_id,  $lang_id, '$str'
	)";

	if ($instance > 0) {

		if ($str == 'LOAD_APP' || $str == 'APP_LOADED') {

			$query = "INSERT INTO `tracking` (
			`APPLICATION_ID`, `LANG_ID`, `INFO`, INSTANCE_ID
			) VALUES (
			$app_id,  $lang_id, '$str', $instance
			)";
		}

	mysql_query("INSERT INTO `tracking_backup` (
	`APPLICATION_ID`, `LANG_ID`, `INFO`, INSTANCE_ID
	) VALUES (
	$app_id,  $lang_id, '$str', $instance
	)");

	mysql_query("UPDATE `instances` SET ACTIVE = 1 WHERE INSTANCE_ID = $instance");

	}

	mysql_query($query);
}
Link to comment
https://forums.phpfreaks.com/topic/281640-undefined-variable/#findComment-1447400
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.