[PHP-users 26287] MySQLでApacheのログを取得・集計したのですが

M.Shimode mitsu @ acquez.co.jp
2005年 7月 25日 (月) 23:28:50 JST


$B$3$s$P$s$o!"2<=P$H?=$7$^$9!#(B
$B$$$D$b3hMQ$5$;$F$$$?$@$$$F$*$j$^$9!#(B

mod_log_sql $B!\(B MySQL$B$G(BApache$B$N%m%0$N=87W$7!"(B
Web$B>e$+$i;2>H$G$-$k$h$&$K$7$h$&$H$7$?$H$3$m(B
mysql$B$X$N(Bquery$B$,$I$&$b$&$^$/$$$+$::$$C$F$$$^$9!#(B
MySQL$B$N;HMQ$O!"$[$H$s$I:#2s$,=i$a$F$K6a$$$N$G$9$,!&!&!&(B

$B$$$m$$$m;n$7$F$O$$$k$N$G$&$9$,!"(B

$B!!(BWarning: mysql_num_rows(): supplied argument is not a valid MySQL result 
resource $B!&!&!&(B

$B$N(Bwarning$B$+$iH4$1=P$;$^$;$s!#(B
$B%G!<%?%Y!<%9$X$N%3%M%/%7%g%s$O3NN)$G$-$F$$$k$H;W$o$l$^$9!#(B

$B%=!<%9$N35MW$O0J2<$N$H$*$j$G$9!#(B

---------------------------------------------------**
<?

$db_host = "localhost";
$db_user = "";
$db_pw   = "******";

$dbname  = "accesslogs";

$d = mysql_connect($db_host, $db_user, $db_pw);
// DB$B%3%M%/%H$N3NG'MQ(B
if(!$d) {
  $dbc = "Error";
  echo $dbc."<br>";
}

//---------$B-!(B
$Root_cnt_Sql = mysql_db_query($dbname, "SELECT * FROM access_log WHERE 
request_uri='/'", $d);
$TP_cnt = mysql_num_rows($Root_cnt_Sql);
//---------$B-!(B

echo "$B!V(B/$B!W$X$N%"%/%;%9N_7W!'(B".$TP_cnt;

?>
---------------------------------------------------**

$B$H$$$C$?46$8$G$9!#(B
$B-!$K$D$$$F$O!"(B

$B!!(B$Root_cnt_Sql = mysql_db_query($dbname, "SELECT count(*) AS cnt FROM 
access_log WHERE request_uri='/'", $d);
$B!!(B$TP_cnt = mysql_result($Root_cnt_Sql, 0, "cnt");

$B$H$NJ}K!$G$b;n$7$F$_$^$7$?$,!"7k2L$OF1$8$/$G$7$?!#(B
MySQL$B$N(BDB$B$X$N@\B38"8B$J$I$O @ _Dj$G$9$7!"FC$KLdBj$O$J$$$H;W$&$N$G$9$,!"(B
$B2?J,$K$b07$$$,IT47$l$J$b$N$G$9$N$G!"$3$A$i$KEj9F$5$;$F$$$?$@$-$^$7$?!#(B

$BCU@[$J<ALd$G62=L$J$N$G$9$,!"$465<($N$[$I$h$m$7$/$*4j$$$$$?$7$^$9!#(B


------------------------**
$B!!(BM.Shimode
$B!!!!(BURL$B!'(Bhttp://hinamail.acquez.co.jp/
$B!!!!(BE-Mail$B!'(Bmitsu @ acquez.co.jp




PHP-users メーリングリストの案内