Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

website tracking code problem

Status
Not open for further replies.

belltekky

MIS
Feb 20, 2010
2
US
I get this error, I think my code needs some cleaning but I can't figure out where the issue is.


Parse error: syntax error, unexpected T_STRING in /home/user/public_html/mydomain.com/tracking.php on line 12


*********code*************
<body>
<?
//connecting to the database we setup
DEFINE(‘DB_HOST’,'localhost’);
DEFINE(‘DB_USER’,'username’);
DEFINE(‘DB_PASS’,'password’);

DEFINE(‘DB_PRIMARY’,'mydatabase’);

mysql_connect(DB_HOST,DB_USER,DB_PASS);
mysql_select_db(DB_PRIMARY);

// Server variables
$ip = $_SERVER['REMOTE_ADDR'];
$referer = $_SERVER['HTTP_REFERER'];
$useragent = $_SERVER['HTTP_USER_AGENT'];

// capturing data we passed in the url
//ie. // I’ve added the engine the click is coming from as
// I’m starting to branch out to other engines now
$keyword = mysql_real_escape_string($keyword);
$source = mysql_real_escape_string($source);

$sql = “INSERT INTO clicks (keyword, source, ip, referer, useragent, time, site) VALUES (‘$keyword’,'$source’,'$ip’,'$referer’,'$useragent’,NOW(),’$site’)”;
mysql_query($sql);

$id = mysql_insert_id();

?>
</body>
*************** end code ************

******* code on index page ******
<?
$site = “domain.com/index1”;
include('?>
<a href=” echo $id; ?>”>link</a>

*************** end code *************


Thanks a million in advance :)
 
am not sure why you are surrounding your php code in <body> tags. equally you should use full php tags unless there is some good reason not to do so.
Code:
<?php ... ?>

there are no errors that I can see in the first block of code that you have posted (save re the $site var on which see below). i am assuming that is tracking.php.

the index.php code looks odd: why are you including tracking.php via the http protocol and not via a file protocol? using the http protocol will mean that teh $site variable is NOT available to the tracking.php script.

the link you post afterwards will not work as you do not correctly open the php tag.
 
Thanks for the reply :)

so what if I use this for the site code

$site=$_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];



and what if I use this for the include

include('../../tracking.php');

I did the above because the file is two directories up.

I also opened all the tags with php including <?php echo $id; ?> in the link.

with the above I still get the t_string error
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top