wkilc Posted November 23, 2015 Share Posted November 23, 2015 (edited) Hi all, I am a PHP novice. I use a script on my site to display multiple table rows with alternating colors and what I believe is called "pagation". (Takes 1,500 rows and displays only 25 or 50 or 100...) Anyway... my host is moving to PHP 5.5 at the end of the month, and when I tested it, it was all good, except for the ability to sort. I think it's this that is the problem: function pparams($sort) {global $sponsor, $school, $student, $instrument, $room, $time;} if (!$sort) $sort = "time"; This is because "register globals" is not supported with 5.5. Any suggestions on how to make it work? Thanks. Edited November 23, 2015 by wkilc Quote Link to comment https://forums.phpfreaks.com/topic/299561-php-55-transition/ Share on other sites More sharing options...
Jacques1 Posted November 23, 2015 Share Posted November 23, 2015 The code you've posted doesn't make sense in any PHP version, because you're defining a function with no effect whatsoever: function pparams($sort) {global $sponsor, $school, $student, $instrument, $room, $time;} And then you try to access the $sort parameter from outside of the function: if (!$sort) $sort = "time"; Obviously the closing brace of the function definition is misplaced. Whether that's a copy-and-paste error or your real code, I don't know. In any case: If you want us to help you, we need the concrete error symptoms, all PHP error messages and all relevant code. It's not enough to tell us what you think is wrong. Quote Link to comment https://forums.phpfreaks.com/topic/299561-php-55-transition/#findComment-1526979 Share on other sites More sharing options...
Stefany93 Posted November 23, 2015 Share Posted November 23, 2015 Yeah dude, what are you trying to accomplish? if you want to put some vars to global you don't need a func for that o_O Quote Link to comment https://forums.phpfreaks.com/topic/299561-php-55-transition/#findComment-1526986 Share on other sites More sharing options...
gizmola Posted November 23, 2015 Share Posted November 23, 2015 global variables as in the type illustrated in your snippet have not been changed at all. I find the name somewhat misleading for many people, because any variable in PHP declared in the "script" scope, is global. However, unlike many other static languages, global variables are not visible inside of functions. Thus the global keyword simply makes an existing global/script variable available inside the function, as in your example. Register globals is a long deprecated and highly insecure feature that when turned on, will automatically make all user and server supplied variables into individually named global variables. This would allow an attacker to attempt to manipulate your apps by calling scripts using lists of get or post, or cookie variables they supply. It has been turned off by default literally for years, and you should not have been using it. If in fact your app is broken for this reason, you should fix it. The superglobals like $_SERVER, $_GET, $_POST etc. exist to provide you user input and url parameters. In general, you can pass variables into your functions, rather than having long lists of globals, but even if you don't fix that, at least make sure you fix the register_globals related code, by finding those places where your code was relying on that, and getting the values from $_GET or $_POST. Quote Link to comment https://forums.phpfreaks.com/topic/299561-php-55-transition/#findComment-1527011 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.