Ask coding questions

← Back to all posts
How to add data to json
samba0648

I'm trying to add data to a JSON when registration is successful.
But it is showing null, can anyone help me in this.

Voters
linusss
samba0648
Comments
hotnewtop
WilliamPenrod

You need to properly format your JSON file.
Just add the [ to the beginning of the JSON file and ] to the end.
Then continue to debug from there :)

samba0648

I tried with adding [] in the JSON file. But this time also only null is adding not the actual [email protected]

samba0648

but in the script, I'm using json_encode() function which will convert the array into json object. So I think no need of adding []@WilliamPenrod

WilliamPenrod

@samba0648 I got it to work by adding [] and fixing some logical errors, so im not sure what to tell you. :)

samba0648

Thanks for your concern. I have fixed [email protected]

WilliamPenrod

@samba0648 Glad to hear it!