Jump to content

Global Var and Functions


xcandiottix

Recommended Posts

I have some variables that I have set with the global command but they don't seem to be working correctly. It's probably my order of operation but not sure. Here's the stripped down version of whats going on:

 

 

locator()

//functions
function geoip()
global $zip, $city, $areacode, $metrocode, $state, $country, $latitude, $longitude;

function locator()
geoip()
use globals from geoip pass to-
ad_display()

function ad_display()
does some work
stat_tracking()

function stat_tracking()
access global $zip, $city, $areacode, $metrocode, $state, $country, $latitude, $longitude;

 

The problem is once I call stat_tracking() and try to access the global variables, they are all empty. Just to clarify the chain of events is: page loads, calls locator(), locator() calls function geoip() fine then passes work to ad_display(), ad_display() calls stat_tracking(), stat_tracking() now tries to access the globals I made but all variables are blank if I echo them.

 

Any ideas?

 

Link to comment
Share on other sites

Got it.

 

after creating

 

global $zip, $city, $areacode, $metrocode, $state, $country, $latitude, $longitude;

 

I needed to call back to these using the format:

$city = $GLOBALS['city'];
$zip = $GLOBALS['zip'];
$areacode = $GLOBALS['areacode'];
$metrocode = $GLOBALS['metrocode'];
$state = $GLOBALS['state'];
$country = $GLOBALS['country'];
$latitude = $GLOBALS['latitude'];
$longitude = $GLOBALS['longitude'];

instead of just using $city, $zip, etc.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.