json_decode returning blank
I am working on facebook app. I have stored some values in database in
json format.
When I am fetching the value on the target page and trying to display the
value as follow :
$sql = mysql_query("select * from `beforepublish` where `tabid` =
'$page_id'") or die(mysql_error());
$sql = mysql_fetch_assoc($sql);
$contest_id = $sql['contestid'];
$temp_id = $sql["tempid"];
$value = $sql["values"];
$returnValue = json_decode($value);
echo "<pre>";
print_r($returnValue);
echo "</pre>";
Here the value of
$value = {"image":"upload_1182341221.jpg","conttxt":"Get a chance to win
Samsung Galaxy Tab "}
and I am getting $returnValue as blank.
but When I try :
$returnValue =
json_decode('{"image":"upload_1182341221.jpg","conttxt":"Get a chance to
win Samsung Galaxy Tab "}');
echo "<pre>";
print_r($returnValue);
echo "</pre>";
then $returnValue is returning :
stdClass Object
(
[image] => upload_1182341221.jpg
[conttxt] => Get a chance to win Samsung Galaxy Tab
)
So guys, please help me, Why I am getting a blank value in the previous
case ?
Edit
vardump($value) is returning :
string '{"image":"upload_1182341221.jpg","conttxt":"Get a chance to win
Samsung Galaxy Tab
"}' (length=86)
No comments:
Post a Comment