Redirect problem :(

Discussion in 'MySQL' started by genius, Dec 28, 2007.

  1. #1
    Hello,

    I've got a problem with my redirect script which I have been using for a while now , but starting from yesterday my host has switched to mysql 5 and apache 2.x.The script is ip2nation maybe some of you know it anyway I'll post it here :

    <?php
    	
    	$server   = ''; // MySQL hostname
    	$username = ''; // MySQL username
    	$password = ''; // MySQL password
    	$dbname   = ''; // MySQL db name
    	
    	
    	$db = mysql_connect($server, $username, $password) or die(mysql_error());
    	      mysql_select_db($dbname) or die(mysql_error());
    			
    	$sql = 'SELECT 
    	            country
    	        FROM 
    	            ip2nation
    	        WHERE 
    	            ip < INET_ATON("'.$_SERVER['REMOTE_ADDR'].'") 
    	        ORDER BY 
    	            ip DESC 
    	        LIMIT 0,1';
    	
    	list($country) = mysql_fetch_row(mysql_query($sql));
    	
    	switch ($country) {
    		case 'se':
    			// Get the swedish to a swedish newssite
    			header('Location: http://www.thelocal.se/');
    			exit;
    		case 'us':
    			// And let the folks from american go to CNN
    			header('Location: http://www.cnn.com/');
    			exit;
    		default:
    			// The rest can go to BBC
    			header('Location: http://www.bbc.co.uk/');
    			exit;
    	}
    	
    ?>			
    Code (markup):

    This and a sql database from http://www.ip2nation.com worked and they redirected the visitors from my country to the page that I wanted and the rest to the english version of the site.Now all visitors go to www.rsgsm.com/index.htm which is the page in english.I've tried to fix it but it just won't work..if you have any ideeas please help me :confused:

    Hope this is the right section for this topic..
     
    genius, Dec 28, 2007 IP
  2. genius

    genius Well-Known Member

    Messages:
    535
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    108
    #2
    Doesn't anybody know ?
     
    genius, Dec 29, 2007 IP
  3. kendo1979

    kendo1979 Peon

    Messages:
    208
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    since i don't see www.rsgsm.com/index.htm anywhere in the script, can you provide the script you currently use?
     
    kendo1979, Dec 30, 2007 IP