I'm having trouble where I wanted to check if the user_name is empty then it will echo YES. But now I din get any of the echo results. I received:
Error: Commands out of sync; you can't run this command now {"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;
}
So, what my problem and how to solve? I had tried finding the answers and solutions on web but none of it works. Thanks for guidance and advice.