I have managed to get part of this code working.
The variables will echo without problem but as soon as I try and put them into the javascript tag they stop working.
What am I doing wrong??
<?php
$id_1 = $_GET['id'];
$tag_id = "tag_id";
$Activity_Tag_String = "Activity_Tag_String";
$group_tag_string = "group_tag_string";
$link = mysqli_connect("localhost", "username", "password", "database");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$query = "SELECT $tag_id, $Activity_Tag_String, $group_tag_string, advertiser_id FROM tbl_tags WHERE advertiser_id = '$id_1'";
$result = mysqli_query($link, $query);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Mate Example</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
</head>
<body>
<script type="text/javascript">
var branch = window.location.href;
var axel = Math.random() + "";
var a = axel * 10000000000000;
document.write('<iframe src="http://fls.doubleclick.net/activityi;src=<?php $tag_id?>;type=<?php $Activity_Tag_String?>;cat=<?php $group_tag_string?>;u1='';ord=' + a + '?" width="1" height="1" frameborder="0" style="display:none"></iframe>');
</script>
</body>
</html>
should be
or
Your version is simply doing the PHP equivalent of:
which is a do-nothing statement. You need to actually echo that variable’s contents.
As well, note that your code is vulnerable to SQL injection attacks, and you should fix that before you do anything else.