Php 如何将数组的整数添加到变量
每次更新时,tcount保留1。为什么会出现这种情况?如果使用int,就不需要像这样在变量上加引号Php 如何将数组的整数添加到变量,php,mysql,pdo,Php,Mysql,Pdo,每次更新时,tcount保留1。为什么会出现这种情况?如果使用int,就不需要像这样在变量上加引号 mysql (table name is accessNum) is pagename(varchar(255)) = index.html, today(date) = 2015-08-31, tcount(int(11)) = 1, totalcount(int(11)) = 1, 在SELECT查询中,不需要在列名周围加引号 if (sizeof($stmt) != 0) { $c
mysql (table name is accessNum) is
pagename(varchar(255)) = index.html,
today(date) = 2015-08-31,
tcount(int(11)) = 1,
totalcount(int(11)) = 1,
在
SELECT
查询中,不需要在列名周围加引号
if (sizeof($stmt) != 0) {
$counter = $record['tcount'];
$counter++;
$dbh->exec("update accessNum set tcount = $counter where pagename = '$pagename'");
}
$stmt = $dbh->query("select tcount from accessNum where pagename = '$pagename'");
此外,在UPDATE
查询中,不需要在数字周围加引号
if (sizeof($stmt) != 0) {
$counter = $record['tcount'];
$counter++;
$dbh->exec("update accessNum set tcount = $counter where pagename = '$pagename'");
}
$stmt = $dbh->query("select tcount from accessNum where pagename = '$pagename'");
总是用反勾号转义列和表名,用引号转义值。在MySQL中,它们是完全不同的。这应该起作用:
$dbh->exec("update accessNum set tcount = $counter where pagename = '$pagename'");
结束报价表
'tcount'
!!从查询中选择“tcount”将直接选择字符串“tcount”
。它将不会获取该列的值。这就像执行选择1
。对不起,我知道会发生什么。