Jump to content

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


Joak

Recommended Posts

Hello guys

 

I Have to try to build an array that has a tree structure(4 levels), but I have gotten an error when I tried to put the 2 level ... commands out of sync; you can't run this command now.

 

I attached a file with the code, what's wrong?

 

 

Regards.

 

 

code.txtFetching info...

Without downloading and looking at your code I'm going to say

 

If you use unbuffered queries, with PDO or mysqli or whatever, then you have to completely read one query's results before you can run another. In rough order of preference your solutions are:

1. Use JOINs to get all the data you need at once without having to issue queries inside loops. A little bit more work but gives much better performance.

2. Use buffered queries. The alternative in case you can't get #1 to work. (I say "the alternative" because #3 is so bad you shouldn't even consider it.)

3. Keep the unbuffered queries but read out all the data into a temporary array and loop over that. Also known as "doing buffered queries the wrong way".

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.