函數get_browser將返回一個相當大的數組,其中包含有關用戶的所有信息。
你應該把這個陣列中的一個數據庫,大概與每一條信息是get_browser()返回列:
$browser = get_browser()
print_r($browser);
foreach ($browser as $key => $information) { // You may want to use array_walk for this, wich is harder to read in a simple example.
$browser_clean[$key] = mysql_real_escape_string($information); //DO NOT FORGET TO SANITIZE, ppl can spoof the browserstrings and open up SQL injection holes!
}
//You probably want some slightly cleaner and better way to talk to the Database then boiling up some ugly SQL-string, though.
mysql_query('INSERT INTO browserstats (parent, platform, browser, ...restofyourfields) VALUES ('. $browser_clean['parent'] .','. $browser_clean['platform'] .','. $browser_clean['browser'] .'...restofthefields)')
;
你究竟在數據庫中存儲了什麼? 'Firefox Mac OS X'就是你正在存儲的東西? – codaddict 2010-09-22 08:44:52