Databases for Sale


| Home Page | Best Offer! | Contact Us | Databases and Software For Sale | Read Our Blog |

Problems With Variables Not Being Passed To A Page

- July 6, 2009, 2:59 pm | Coding Tips

Add to register globals php.ini phpdel.icio.us | Problems With Variables Not Being Passed To A PageDigg


Variables not being passed most often happens because of one of two reasons. The first, and least likely, is when your PHP is corrupted. Fixing this would require a new PHP install. But the issue is likely that you do not have register_globals (php.ini) turned on.

register globals php.ini php
Register Globals issues comes down to three quick solutions.

A lot of hosting companies do not turn register_globals on by default. It can open up some security risk. However, our code is pretty innocuous. Other than passing a keyword or two from one page to another, there is not much else going on that requires register_globals to be turned on.

To do this you usually have three options.

1. If you have your own server, you can turn register_globals on by editing the php.ini file. The problem with this is that register globals will be enabled for every site on the server.

2. You can add the following line in your .htaccess file: php_flag register_globals 1. (1=on; 0=off if your PHP is running as an APACHE Module, or simply on/off if PHP is running as CGI)  So on some servers you can set this line to: php_flag register_globals on. Sometimes, this will will give you a server error when you access your site, so try `1` and `on` unless you know how PHP is running on your server. If it gives you a server error for both options step 3 will likely work.

3. Get a copy of your php.ini file and edit the register_globals line to turn it on. Then place this file into the root of your web site.

If number 2 above does not work then number three is a good solution.

Of course there are always going to be situations where the steps above will not work for some reason.

The following code will emulate register_globals being on by accessing predefined variables in the superglobal arrays. This solution not only works for current scripts looking for register_globals to be on, but on legacy scripts that have not been updated is a long time. 


<?php
if (!ini_get(`register_globals`
)) {
    
$superglobals = array($_SERVER, $_ENV
,
        
$_FILES, $_COOKIE, $_POST, $_GET
);
    if (isset(
$_SESSION
)) {
        
array_unshift($superglobals, $_SESSION
);
    }
    foreach (
$superglobals as $superglobal
) {
        
extract($superglobal, EXTR_SKIP
);
    }
    
ini_set(`register_globals`, true
);
}
?>


And, of course, if you have any questions or need help in any way, please contact us.






Keywords: register globals php.ini php
Articles on register globals php.ini php News on register globals php.ini php Videos on register globals php.ini php


Recently Added:
  1. Problems With Variables Not Being Passed To A Page - Coding Tips
  2. 12,000,000 Page Web Site - 12 Million Page Web Site
  3. Converting CSV Files To SQL The Easy Way - Working With Data
  4. Mod Rewrite For SE Friendly URLs A Practical Example - Coding Tips
  5. Read This Before You Buy A Database - Database Notices

Blog Categories:
12 Million Page Web Site
Coding Tips
Database Notices
Working With Data

Our Shop:
Business Contact Databases
Business Databases
Database Collections
International Databases
Misc Databases
Niche Databases
Optin Email
Resellers
Residental White Pages
Software
Software and Databases
Zip Code Databases


Documents:
Frequently Asked Questions
Privacy Notice
Return Policy
Terms and Conditions

| Home Page | Best Offer! | Contact Us | Databases and Software For Sale | Read Our Blog |

Copyright © 1993-2009 USPN Tech, All Rights Reserved