TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Bug Alert Google Adsense Flips out Mysql

1 点作者 agentbleu将近 17 年前
While recently building a new App. I ran into a nasty bug that trips Mysql up in very strange and unpleasing way. So here's how to repeat this. You set up a simple table 'yourtable' with 2 columns, 'id' (int) which is set to auto_increment and 'name' (for example). Then run this simple script on a unique (this part is important) named page, for example call you file unique-1.php each time you call this file change the name!<p>what will happen is that instead of the expected 1 row inserted into to DB you will get 3 rows all repeats of the one expected. Change the name of the file to unique-2.php load again and you will get another 3 insertions. I have tested this on 2 completely separate servers with different distros, same results every time. It also happens with any Adsense advert whatsoever. Considering the nature of this bug I'm suprisesd no answer has come back from Google on this (over a week since reported). I imagine databases filled up with 3 times as much data as necessary all over the web!<p>Heres the code: &#60;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&#62; &#60;html&#62; &#60;head&#62; &#60;title&#62;Test bug&#60;/title&#62; &#60;meta http-equiv="content-Type" content="text/html; charset=iso-8859-1"&#62; &#60;/head&#62; &#60;body&#62; &#60;div id='vu_ytplayer_vjVQa1PpcFPb8BUW_RRt-RtcJhs9CmRKZDf2_gtwvfw='&#62;&#60;a href='http://www.youtube.com/browse'&#62;Watch the latest videos on YouTube.com&#60;/a&#62;&#60;/div&#62;&#60;script type='text/javascript' src='http://www.youtube.com/cp/vjVQa1PpcFPb8BUW_RRt-RtcJhs9CmRKZDf2_gtwvfw='&#62;&#60;/script&#62; &#60;/body&#62; &#60;/html&#62;<p>&#60;?php<p>$server = "localhost"; // Server Host<p>$DBpassword = ""; // Database Password<p>$DBusername = ""; // Database Username<p>$database = ""; // Database Name<p>mysql_connect($server, $DBusername, $DBpassword) or die ("Database CONNECT Error ()");<p>mysql_select_db($database); $GetEmail = mysql_query("INSERT INTO yourtable ( id, name ) VALUES ( '', 'test' )") or die ("Database Email Error"); ?&#62;

2 条评论

justinsb将近 17 年前
It sounds like AdSense is automatically crawling your page to determine which ads to serve in future. I guess if it matters to your app, you'd probably want to figure out the Google IP addresses and exclude them from writing to the DB.<p>You could verify this by posting your HTTP access log.<p>This hadn't occurred to me previously, and I couldn't find anything about it, but I don't see how else Adsense could work.<p>I would imagine it only happens once per page, hence the need to keep changing the file name.
评论 #231822 未加载
agentbleu将近 17 年前
interesting analysis