我写了一个简单的bash脚本来监控我的网站.
#!/bin/bash
# script to check website status (online/offline)
while read site
do
if ping -w 60 -c1 -q "$site" &>/dev/null; then
echo "$site is up"
else
echo "[$(date +%d-%m-%Y:%H:%M:%S)] $site is not reachable." | slackpost.sh
fi
done < /home/pi/scripts/www-status/sites.txt # list of sites to check
Run Code Online (Sandbox Code Playgroud)
但有时...$site is not reachable. ...即使网站上线,我也会受到阻碍.
有什么想法可能导致糟糕的砰?
我有桌子.我需要在我的查询中计算一些字段.这是我的查询:
select COUNT(q1) as 'result'
from (select DISTINCT id_qs as 'q1' FROM main where id_exam=40) as q2
Run Code Online (Sandbox Code Playgroud)
这是查询完美的工作.但.当我把它放在PHP代码中:
function HowManyQuestion($id)
{
mysql_connect($this->hostname,$this->username,$this->password) OR DIE("Can't connect");
mysql_select_db($this->dbName) or die(mysql_error());
$query = "select COUNT(q1) as 'result' from (select DISTINCT id_qs as 'q1' FROM main where id_exam=40) as q2;";
$res = mysql_query($query) or die(mysql_error());
$id=0;
while ($row=mysql_fetch_array($res)) {
$id=$row['result'];
break;
}
return $id;
}
Run Code Online (Sandbox Code Playgroud)
结果我有错误:
您的SQL语法有错误; 检查与您的MySQL服务器版本相对应的手册,以便在第1行的'q2'附近使用正确的语法
那怎么解决?