Commands out of sync; you can't run this command now I have a query which was working fine a few days back:
SELECT
    id, title, details, filetype, filepath, size, details, location, datetime, 
    IF(hid=1, 'Anonymous',
        (
            SELECT name 
            FROM users 
            WHERE did = userid
        ))
    AS username 
FROM infotable 
WHERE ext2!='0' 
ORDER BY id DESC 
LIMIT 50

but a couple of days back, it started giving an error:

Commands out of sync; you can't run this command now

I am calling it from a PHP page but I have also tried it from MySQL's GUI to run it as SQL query. It gave the the same error:

When I googled, I found that it may be due to MySQL to MySQLi update. I tried a lot to write an alternate query using MySQLi, but every time I got an error (Some times the same error and some times other errors).
My questions are:
1. What this can be called as: Sub Query or Multi Query
2. What is the exact error and what is its solution?
I think this Stack Overflow question is related to your query:

PHP Commands Out of Sync error

It's because results are not completely fetched before another call. PHP docs has a solution read this too:

http://www.php.net/manual/en/mysqli.query.php#102904