MySQL查询是否可能太长,并导致一些问题?
我想将browser_version、平台和user_agent等从用户保存到数据库中。
我使用this类并拥有以下代码:
include_once('database_connect.php');
include_once('clean.php');
include_once('class.browserversion.php');
$browser = new Browser();
$browser_name = clean($browser->getBrowser());
$browser_version = clean($browser->getVersion());
$browser_platform = clean($browser->getPlatform());
$browser_is_mobile = clean($browser->isMobile());
$browser_user_agent = clean($browser->getUserAgent());
if($browser_is_mobile == FALSE):
$browser_is_mobile = 0;
elseif($browser_is_mobile == TRUE):
$browser_is_mobile = 1;
endif;
$qry = "INSERT INTO map_user_browser (user_id, browser_name, browser_version, browser_platform, browser_is_mobile, browser_user_agent) VALUES('".$user_id."', '".$browser_name."', '".$browser_version."', '".$browser_platform.", '".$browser_is_mobile."', '".$browser_user_agent."'";
$result = @mysql_query($qry) or die(mysql_error());我总是收到错误,上面写着You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '0', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_0) AppleWebKit/537.36 (KHTML, l' at line 1
但是,当我对每个字段进行几次查询时,一切都可以工作。有什么不对的?
发布于 2013-12-04 15:46:08
试试这个:
$qry = "INSERT INTO map_user_browser (user_id, browser_name, browser_version, ".
"browser_platform, browser_is_mobile, browser_user_agent) VALUES('".$user_id."', ".
"'".$browser_name."', '".$browser_version."', '".$browser_platform."', ".
"'".$browser_is_mobile."', '".$browser_user_agent."')";您错过了'在$browser_platform和之后“)”在查询结束时的。
https://stackoverflow.com/questions/20379654
复制相似问题