Jump to content

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


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.txt

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".

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.