Jump to content

[SOLVED] Var returned by function is empty


keeps21

Recommended Posts

I have a  page which takes a variable from an URL. Eg /index.php?c=Article

 

// Get variables from url
if ( !isset( $_GET['c'] ) ) {
$controller = 'Article'; // Default to article page showing all articles
} else {
echo "c=".$controller = escape_data($_GET['c']) ;
}

 

The variable from the url is escaped using my escape_data() function and assigned to a variable and echoed out.

 

Here is the escape_data() function.

function escape_data($data) {
if (ini_get('magic_quotes_gpc')) {
	$data = stripslashes(trim($data));
}
$escaped_data = mysql_real_escape_string(trim($data));
return $escaped_data;
}

 

The function is in a separate file but is definitely being included.

 

The problem is on my live server the $controller is empty/not set but on my local server it is working as expected.

 

Also the file works as expected if the escape_data function isn't used, though unescaped data isn't desirable

 

Any ideas?

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.