Hi, I want to use Ip2Nation database to display some advertisements to USA visitors only. Here is the sample code with redirects, but I need 'echo' probably to display some html in page code. <?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; } ?> PHP: Can somebody give me code I need? Thanks in advance, Marko
<?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': //display some banner adverts to the americans echo "<img src='you/already/know/how/to/write/html.jpg'>"; exit; default: // The rest can go to BBC header('Location: http://www.bbc.co.uk/'); exit; } ?> PHP:
Code is printing what I want to US visitors only, but it is not displaying any code below IP2Nation block. Here is code I used: <?php $server = 'localhost'; // MySQL hostname $username = 'my username'; // MySQL username $password = 'my pass'; // MySQL password $dbname = 'my database'; // 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 'us': //display some banner adverts to the americans echo "<p>For Americans</p>"; exit; default: // The rest will not see anything echo ""; exit; } ?> PHP:
Code that was generating the rest of the page bellow. Anyway, this is resolved now. Someone else helped me as you went off line on MSN Mikey. Thanks for your help