I have a script that pulls a dataset from a mysql database. It then converts it into a json object.
My javascript pulls a new item every 5 seconds. The script works ok when the json is properly formed. But when I pull it out of the db and use PHP's json_encode() it doesn't encode it properly, I think.
Script works when I have:
var data = {
posts: [
{
body: "Excellent, 5 stars!"
},
{
body: "Poor, 0 stars"
},
{
body: "Beyond Excellent, 10 stars!"
}
]
};
and this is the code that PHP's json_encode() gives:
var data = {
"posts":[
{"post":{"phone":"+15555555555","status":"0","body":"http:\/\/[login to view URL]"}},
{"post":{"phone":"+15555555555","status":"0","body":"http:\/\/[login to view URL]"}},
{"post":{"phone":"+15555555555","status":"0","body":"[login to view URL]"}},
{"post":{"phone":"+15555555555","status":"0","body":"this is a longer test"}},
{"post":{"phone":"+15555555555","status":"0","body":"test"}}]};
I need to have the body text fade in and out. Attached is the script. One version working (static json elements) and another not working (pulling from the DB). I need to be able to pull from the DB. Shouldn't take the right person maybe 10 minutes to fix I assume. I can give access to the server with the mysql db to get it working.