简体   繁体   English

我的MySQL更新查询出了什么问题?

[英]What's wrong with my MySQL update query?

I started learning php, I'm having some problems with this mysql query 我开始学习php,此mysql查询出现问题

  mysql_query( "UPDATE boardinfo SET totalPostCount = '" . $GLOBALS['postCount'] + 1 . "' WHERE boardName = '" . $_POST['board'] )

Error: near '1' WHERE boardName = 'Site' at line 1 错误:第1行的'1'WHERE boardName ='Site'附近
All I need to do here is to update the value of totalPostCount if it's boardName matches value from $_POST['board'] 我要做的就是更新totalPostCount的值,如果它的boardName与$ _POST ['board']中的值匹配
Please, go easy on me, I've only started this yesterday... 拜托,放轻松我,我昨天才开始这个...

In your statement, quotes are not closed in last. 在您的陈述中,引号最后没有关闭。

 mysql_query( "UPDATE boardinfo SET totalPostCount = '" .$GLOBALS['postCount'] + 1 . "' WHERE boardName = '" . $_POST['board']."'" )

If it doesn't solve your issue,try one more thing. 如果仍不能解决您的问题,请再尝试一件事。

$val = $GLOBALS['postCount'] + 1;
mysql_query( "UPDATE boardinfo SET totalPostCount = '" .$val . "' WHERE boardName = '" . $_POST['board']."'" )

Hope it will solve your problem 希望它能解决您的问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM