-1
我已經設法讓這段代碼的一部分工作。如何將變量放入JavaScript標記中?
變量將回顯沒有問題,但只要我嘗試將它們放入JavaScript標記,他們停止工作。
我在做什麼錯?
<?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>
檢查生成的輸出。 –
您需要'<?php echo $ var;?>' –
MySQL標籤和代碼與這個問題無關。 – j08691