keeps21 Posted February 25, 2009 Share Posted February 25, 2009 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? Link to comment https://forums.phpfreaks.com/topic/146854-solved-var-returned-by-function-is-empty/ Share on other sites More sharing options...
keeps21 Posted February 25, 2009 Author Share Posted February 25, 2009 Even the following doesn't work on the live server, but does on the locahost. $controller = mysql_real_escape_string($_GET['c']); Could this be a php issue? Link to comment https://forums.phpfreaks.com/topic/146854-solved-var-returned-by-function-is-empty/#findComment-770979 Share on other sites More sharing options...
keeps21 Posted February 25, 2009 Author Share Posted February 25, 2009 Ah I believe I've found the problem. The database connection $dbc was not made public in the function that connects to the database. Now that I've madwe $dbc public the function is working as expected. Link to comment https://forums.phpfreaks.com/topic/146854-solved-var-returned-by-function-is-empty/#findComment-770988 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.