Jump to content

Problem with google maps geo-location code or insert into db


sandy4

Recommended Posts

Help!

 

I have a problem with my php and mysql database in that it won't insert into the members database the ip_long and ip_lat information, however it has inserted the ip address and the other user details correctly.

 

Here is what happens, user creates a new account, fill in all his/her details and click submit. In my members database table it shows everything recorded except the ip_long, ip_lat, ip_country, and ip_code.

 

If I fill in manually a latitude and longitude country and code in my members table the google maps marker appears correctly placed. So again my question would be whats stopping it inserting those values?

 

 

My code below:

//////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////
function AddMember($data, $extra){



/*
	THIS FUNCTION WILL GENERATE A NEW MEMBER ACCOUNT
*/

global $DB;

$user = str_replace(" ", "", strip_tags($data['username']));
$email = str_replace(" ", "", strip_tags($data['email']));
$pass = str_replace(" ", "", strip_tags($data['password']));
$default_CC ="United States";  
$MSGSTATUS= D_STATUSMSG;

$ip = $_SERVER['REMOTE_ADDR']; 
$session = session_id();

$member_Package_id = DEFAULT_PACKAGE;

// DETERMINE ACCOUNT STATUS
if(APPROVE_ACCOUNTS == "yes"){ 
	$status = "unapproved"; 
}else{ $status = "active"; }


////////////////////////////////
## FIRST LETS GET THE DATA FROM THE PACKAGES
$packageData = $DB->Row("SELECT * FROM package WHERE pid='".$member_Package_id."' LIMIT 1");

////////////////////////////////////////////
//   GEOIP SYSTEM DETECTION    //
$reg_long=""; $reg_lat=""; $reg_country=""; $reg_code="";

if(!isset($_SESSION['clever_ip_country']) && MAPS_ID !="" && GOOGLE_MAPS_KEY !=""){

	$exe_data = explode(",",ValidateExternalCountry($_SERVER['REMOTE_ADDR']));
	if(is_array($exe_data) && $exe_data != 0){			
		$reg_long=$exe_data[4]; $reg_lat=$exe_data[3]; $reg_country=$exe_data[2]; $reg_code=$exe_data[0];			
	}

}elseif( isset($_SESSION['clever_ip_long']) ){

		$reg_long	 	= $_SESSION['clever_ip_long'];
		$reg_lat 		= $_SESSION['clever_ip_lat'];
		$reg_country 	= $_SESSION['clever_ip_country'];
		$reg_code 		= $_SESSION['clever_ip_code'];
		$default_CC  	= $_SESSION['clever_ip_country_name'];

}elseif(isset($data['country'])){

	$reg_country = $data['country'];
	$default_CC =$data['country'];
}

if(D_MD5 ==1){
	$passcode = md5($pass);
}else{
	$passcode = $pass;
}
/////////////////////////////////////////////
$DB->Insert("INSERT INTO `members` ( `id` , `username` , `password` , `email` , `session` , `ip` , `lastlogin` , `visible` , active, `created`, packageid, hits, profile_complete, templateid, updated, moderator, activate_code, highlight, ip_long, ip_lat, ip_country, ip_code,member_rating,  msgStatus,  video_duration,  video_live )
			VALUES (NULL , '".$user."', '".$passcode."', '".$email."', '".$session."', '".$ip."', '".DATE_TIME."', 'yes', '".$status."', '".DATE_TIME."', '".$member_Package_id."','0','0','1','".DATE_TIME."', 'no', 'OK','off','".$reg_long."','".$reg_lat."','".$reg_country."','".$reg_code."', '0','".goodInput($MSGSTATUS)."','0','no')");
$userid = $DB->InsertID();

 

echo out these to see if they are set:

 

$reg_long      = $_SESSION['clever_ip_long'];

        $reg_lat      = $_SESSION['clever_ip_lat'];

        $reg_country    = $_SESSION['clever_ip_country'];

        $reg_code      = $_SESSION['clever_ip_code'];

        $default_CC    = $_SESSION['clever_ip_country_name'];

check to make sure you sessions variables are correct. should it be $_SESSION['Clever_IP_country'] or any other combination of uppercase, or lowercase letters. also make sure you put session_start() at the beginning of your php page

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.