阅读 桌面完整版
最近把我的英文算法论坛给升级到PHPBB3.15可是就发现网络爬虫 e.g. GOOGLEBOT 在浏览论坛的时候其实是会报错的.
可以用第三方网络 sniffer 或者用 CHROME的一个 user agent switcher 的插件把 user agent 设置成:
Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)
这是由 /forum/phpbb/user.php 文件的第 235 行有错误引起的.
1 2 3 4 5 6 7 | $sql = 'SELECT * FROM ' . STYLES_TABLE . " s WHERE s.style_id = $style_id"; $result = $db->sql_query($sql, 3600); $this->style = $db->sql_fetchrow($result); $db->sql_freeresult($result); |
$sql = 'SELECT * FROM ' . STYLES_TABLE . " s WHERE s.style_id = $style_id"; $result = $db->sql_query($sql, 3600); $this->style = $db->sql_fetchrow($result); $db->sql_freeresult($result);
很明显 当变量 $style_id 为空时, SQL 就有语法错误. 最简单的方法就是把这个变量用单引号框起来:
1 2 3 4 5 6 7 | $sql = 'SELECT * FROM ' . STYLES_TABLE . " s WHERE s.style_id = '$style_id'"; $result = $db->sql_query($sql, 3600); $this->style = $db->sql_fetchrow($result); $db->sql_freeresult($result); |
$sql = 'SELECT * FROM ' . STYLES_TABLE . " s WHERE s.style_id = '$style_id'"; $result = $db->sql_query($sql, 3600); $this->style = $db->sql_fetchrow($result); $db->sql_freeresult($result);
或者在这之前加一句判断:
1 | if (!$style_id) $style_id = 0; |
if (!$style_id) $style_id = 0;
当然最好把 表名, 表字段用 ` 框起来, 这些都是良好编程的习惯.
英文: https://helloacm.com/how-to-fix-phpbb3-1-5-general-error-for-bots/
强烈推荐
- 英国代购-畅购英伦
- TopCashBack 返现 (英国购物必备, 积少成多, 我2年来一共得了3000多英镑)
- Quidco 返现 (也是很不错的英国返现网站, 返现率高)
- 注册就送10美元, 免费使用2个月的 DigitalOcean 云主机(性价比超高, 每月只需5美元)
- 注册就送10美元, 免费使用4个月的 Vultr 云主机(性价比超高, 每月只需2.5美元)
- 注册就送10美元, 免费使用2个月的 阿里 云主机(性价比超高, 每月只需4.5美元)
- 注册就送20美元, 免费使用4个月的 Linode 云主机(性价比超高, 每月只需5美元) (折扣码: PodCastInit2022)
- PlusNet 英国光纤(超快, 超划算! 用户名 doctorlai)
- 刷了美国运通信用卡一年得到的积分 换了 485英镑
- 注册就送50英镑 – 英国最便宜最划算的电气提供商
- 能把比特币莱特币变现的银行卡! 不需要手续费就可以把虚拟货币法币兑换
微信公众号: 小赖子的英国生活和资讯 JustYYUK