函数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