Jon12345 Posted December 15, 2006 Share Posted December 15, 2006 Does the following code need to be run before any output to the webpage? Or does it have to be in the header section?[code] $ipaddress=$_SERVER['REMOTE_ADDR']; [/code]Thanks,Jon Quote Link to comment Share on other sites More sharing options...
complex05 Posted December 15, 2006 Share Posted December 15, 2006 can be run anywhere. Quote Link to comment Share on other sites More sharing options...
taith Posted December 15, 2006 Share Posted December 15, 2006 you can use that wherever you likesthe only things that need to be prior to any output are things that are not sent along with the headers(cookies, session_start, print, etc) Quote Link to comment Share on other sites More sharing options...
Jon12345 Posted December 15, 2006 Author Share Posted December 15, 2006 Oh that's good to know, although it brings up a fresh problem. The following code is intended to lookup my database to see if there is a matching ipaddress and if there is, set action=1 in the records action field. But instead, I just get a blank screen and no redirect. If I eliminate the database code section, it redirects. What is wrong with my code?[code]$ipaddress=$_SERVER['REMOTE_ADDR']$db1=mysql_connect("localhost","user","pw"); mysql_select_db("affiliatelog",$db1);$query1="UPDATE visitor_log SET action = '1' WHERE ipaddress='$ipaddress'"; mysql_query($query1) or die('Database Query Error: '.mysql_error()); mysql_close($db1)$sub=$_GET['sub'];$offer=$_GET['offer'];if ($offer == "xxx") {$product = "http://site1.com?sub=$sub";} // Default linkif ($offer == "bbb") {$product = "http://site2.com/?sub=$sub";} // Default link//some javascript redirect code goes here but this forum won't let me post it for some strange reason![/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.