Ho appena installato il db iptolocation che dovrebbe funzionare tramite una pagina php effettuando il redirect, ma ricevo un'errore
Parse error: parse error, unexpected $ in /home/*****/luckymask.com/start.php on line 103
e questa è la pagina:
Codice PHP:
<?php
// Replace this MYSQL server variables with actual configuration
$mysql_server = "*******";
$mysql_user_name = "*****";
$mysql_user_pass = "*****";
// Retrieve visitor IP address from server variable REMOTE_ADDR
$ipaddress = getenv(REMOTE_ADDR);
// Convert IP address to IP number for querying database
$ipno = Dot2LongIP($ipaddress);
// Connect to the database server
$link = mysql_connect($mysql_server, $mysql_user_name, $mysql_user_pass) or die("Could not connect to MySQL database");
// Connect to the IP2Location database
mysql_select_db("lucky") or die("Could not select database");
// SQL query string to match the recordset that the IP number fall between the valid range
$query = "SELECT * FROM ipcountry WHERE $ipno <= ipTO AND $ipno>=ipFROM";
// Execute SQL query
$result = mysql_query($query) or die("lucky Query Failed");
// Retrieve the recordset (only one)
$row = mysql_fetch_object($result);
// Keep the country information into two different variables
$countrySHORT = $row->countrySHORT;
$countryLONG = $row->countryLONG;
// Free recordset and close database connection
mysql_free_result($result); mysql_close($link);
//-------------------------------------------------------
// If the visitors are from ITALY
if ($countrySHORT == "IT")
{
Header("Location: it/index.php");
} else {
//-------------------------------------------------------
// If the visitors are from FRANCE
if ($countrySHORT == "FR")
{
Header("Location: fr/index.php");
} else {
//-------------------------------------------------------
// If the visitors are from SPANISH
if ($countrySHORT == "ES")
{
Header("Location: es/index.php");
} else {
//-------------------------------------------------------
// If the visitors are from RUSSIAN
if ($countrySHORT == "RU")
{
Header("Location: ru/index.php");
} else {
//-------------------------------------------------------
// If the visitors are from BULGARIA
if ($countrySHORT == "BG")
{
Header("Location: bg/index.php");
} else {
//-------------------------------------------------------
// If the visitors are from UNITED KINGDOM
if ($countrySHORT == "GB")
{
Header("Location: bg/index.php");
} else {
//-------------------------------------------------------
// Otherwise, redirect them to INTERNATIONAL site
Header("Location: uk/index.php");
}
exit;
// Function to convert IP address (xxx.xxx.xxx.xxx) to IP number (0 to 256^4-1)
function Dot2LongIP ($IPaddr) {
if ($IPaddr == "")
{
return 0;
} else {
$ips = split ("\.", "$IPaddr");
return ($ips[3] + $ips[2] * 256 + $ips[1] * 256 * 256 + $ips[0] * 256 * 256 * 256);
}
}
?>
La riga 103 a me risulta essere ?>
Avete qualche suggerimento per risolvere il problema?
TX