Firebase php invalid character value error

226 views Asked by At

Using firebase php, I am getting following error in a simple $firebase->set($data,$location) function.

Uncaught exception 'Kreait\Firebase\Exception\FirebaseException' with message 'The location key "rural foothills m.d." contains on of the following invalid characters: .$#[]'

Is there a way to sanitize the value to avoid the error?

Thanks!

1

There are 1 answers

0
aofdev On

Sometimes you will see an error that says "Invalid data; couldn't parse JSON object, array, or value. Perhaps you're using invalid characters in your key names."

This error occurs when the fields you are trying to send to Firebase contain invalid characters. Firebase prohibits key names from containing:

. (period)
$ (dollar sign)
[ (left square bracket)
] (right square bracket)
# (hash or pound sign)
/ (forward slash)

To get around the error, you will need to manually assign names to the keys.

Reference: Common Problems with Firebase