我遇到了麻烦,我想检查user_name是否为空,那么它会回显YES。但是现在我可以得到任何回声结果。我收到:如何检查数据库中的字段是否为空?
错误:命令不同步;你现在不能运行这个命令{“success”:1}
if ($result = $mysqli->query("SELECT user_name FROM user WHERE user_id = '33'", MYSQLI_USE_RESULT)){
while ($row = mysql_fetch_array($result)) {
if($row['user_name']===' '){
echo "YES";
}
}
/* Note, that we can't execute any functions which interact with the
server until result set was closed. All calls will return an
'out of sync' error */
if (!$mysqli->query("SET @a:='this will not work'")) {
printf("Error: %s\n", $mysqli->error);
}
$result->close();
$json['success'] = 1;
}else{
$json['success'] = 7;
}
那么,我的问题和如何解决?我曾尝试在网上找到答案和解决方案,但没有一个可行。 感谢您的指导和建议。
你把空间,在你,如果声明==='' –
@ Savage Leo [this](http://stackoverflow.com/questions/15798762/mysqli-commands-out-of-sync-you-cant-run-this-command-now)问题可能帮助你了解什么是错的。 – Gunaseelan