Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Cannot redeclare get_domain() - please help
Old 09-09-2011, 06:17 PM Cannot redeclare get_domain() - please help
Super Talker

Posts: 107
Name: Lorenzo Tanghal
Trades: 0
Hi,

I am not a coder and I really appreciate your help. I don't know what to do. If you will visit my site http://www.flamingwheels.com/ you will get an error Fatal error: Cannot redeclare get_domain() (previously declared in /home/flamingw/public_html/in.php:2) in /home/flamingw/public_html/in.php on line 8

Below is the code. Please help.

<
?php
function get_domain($url){
$refdomain = preg_match('@^(?:http://)?([^/]+)@i',$url, $matches);
$host = $matches[1];
preg_match('/[^.]+\.[^.]+$/', $host, $matches);
$refdomain = $matches[0];
return $refdomain;
}

$ref1 = $_SERVER['HTTP_REFERER'];
$ref2 = get_domain($ref1);
//$base1 = "http://".$_SERVER["HTTP_HOST"];
//$base2 = get_domain($base1);

if(!empty($ref2)){

//if($ref2!=$base2){

$trade_options=get_option(abb_trade_settings);

if($trade_options[geotrading]!=1){
if(!empty($_SERVER['HTTP_CLIENT_IP'])) $ip=$_SERVER['HTTP_CLIENT_IP'];
elseif(!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
else $ip=$_SERVER['REMOTE_ADDR'];
}else{
include_once('ip2c/ip2country.php');
$ip2c=new ip2country();
$ip=$ip2c->get_client_ip();
$ipc=$ip2c->get_country_name();
$ipcc=$ip2c->get_country_code();
}

$post_id = $post->ID;
$now=time();
$query1=mysql_query("SELECT ipaddress FROM trade_ipaddress WHERE ipaddress='$ip' && websiteurl='$ref2' LIMIT 1") or die(mysql_error());

if(mysql_num_rows($query1)==0){

if($trade_options[geotrading]!=1){

$insert=mysql_query("INSERT INTO trade_ipaddress (ipaddress,websiteurl,fullurl,post_id,io,time) VALUES ('$ip','$ref2','$ref1','$post_id','1','$now')") or die(mysql_error());
$update=mysql_query("UPDATE trade_sites SET totalin=totalin+1,dayin=dayin+1 WHERE websitename='$ref2' LIMIT 1") or die(mysql_error());

}else{

$insert=mysql_query("INSERT INTO trade_ipaddress (ipaddress,country,country_code,websiteurl,fullurl ,post_id,io,time) VALUES ('$ip','$ipc','$ipcc','$ref2','$ref1','$post_id',' 1','$now')") or die(mysql_error());

$tiercredit=0;

$tier0listexplode=explode(',',$trade_options[tier0]);
for($x=0;$x<count($tier0listexplode);$x++){if($ipc ==$tier0listexplode[$x]){$tiercredit=1;
$update=mysql_query("UPDATE trade_sites SET totalin=totalin+1,dayin=dayin+1,tier0credit=tier0c redit+1 WHERE websitename='$ref2' LIMIT 1") or die(mysql_error());}}

if($tiercredit==0){$tier1listexplode=explode(',',$ trade_options[tier1]);
for($x=0;$x<count($tier1listexplode);$x++){if($ipc ==$tier1listexplode[$x]){$tiercredit=1;
$update=mysql_query("UPDATE trade_sites SET totalin=totalin+1,dayin=dayin+1,tier1credit=tier1c redit+1 WHERE websitename='$ref2' LIMIT 1") or die(mysql_error());}}}

if($tiercredit==0){$tier2listexplode=explode(',',$ trade_options[tier2]);
for($x=0;$x<count($tier2listexplode);$x++){if($ipc ==$tier2listexplode[$x]){$tiercredit=1;
$update=mysql_query("UPDATE trade_sites SET totalin=totalin+1,dayin=dayin+1,tier2credit=tier2c redit+1 WHERE websitename='$ref2' LIMIT 1") or die(mysql_error());}}}

if($tiercredit==0){$tiercredit=1;
$update=mysql_query("UPDATE trade_sites SET totalin=totalin+1,dayin=dayin+1,tier3credit=tier3c redit+1 WHERE websitename='$ref2' LIMIT 1") or die(mysql_error());}
}
}
//}
}
?>
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
-
Visit the Famous places and tourist attractions of the Queen City of the South
lhurey is offline
Reply With Quote
View Public Profile Visit lhurey's homepage!
 
 
Register now for full access!
Old 11-10-2011, 03:42 AM Re: Cannot redeclare get_domain() - please help
Junior Talker

Posts: 1
Trades: 0
Change this:

Code:
function get_domain($url){
  
....
 return $refdomain;
}
to

Code:
if (!function_exists("get_domain")){
function get_domain($url){
.....
return $refdomain;
}

}
__________________
>TheDanielSolution

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
danielsolution_FL is offline
Reply With Quote
View Public Profile
 
Old 11-10-2011, 10:43 AM Re: Cannot redeclare get_domain() - please help
Super Spam Talker

Posts: 879
Name: Paul W
Trades: 0
Don't do that - bad! It just masks the issue and could cause problems.

You either have two definitions of the function - the other one would be in a file referenced through an include (or similar) statement. Either that or you have badly done includes. Go through your php files and change

include("whatever.php") to include_once("whatever.php")
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE


*** New:
Please login or register to view this content. Registration is FREE
PaulW is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Cannot redeclare get_domain() - please help
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.41177 seconds with 12 queries