Unserializing & inserting into database ?

Code:
$affiche = utf8_encode($affiche);
$affiche = json_decode($affiche);
var_dump(json_last_error());

gets me

Code:
[h=2]int(4)[/h]
 
That's not json. It's some serialization format that looks like jason, like yaml or something.
 
Also, when I

Code:
[COLOR=#333333][FONT=Consolas]print_r($movie->getArray());[/FONT][/COLOR]

I get

Array (
Code:
 => 205450 [movieType] => Array ( [code] => 4002 [$] => Long-m�trage ) [originalTitle] => Fifty Shades of Grey [title] => Cinquante Nuances de Grey [productionYear] => 2015 [nationality] => Array ( [0] => Array ( [code] => 5002 [$] => U.S.A. ) ) [genre] => Array ( [0] => Array ( [code] => 13010 [$] => Erotique ) [1] => Array ( [code] => 13008 [$] => Drame ) [2] => Array ( [code] => 13024 [$] => Romance ) ) [release] => Array ( [releaseDate] => 2015-02-11 ) [runtime] => 7500 [synopsisShort] => L'histoire d'une romance passionnelle, et sexuelle, entre un jeune homme riche amateur de femmes, et une �tudiante vierge de 22 ans. [castingShort] => Array ( [directors] => Sam Taylor-Johnson [actors] => Jamie Dornan, Dakota Johnson, Jennifer Ehle, Eloise Mumford, Victor Rasuk ) [movieCertificate] => Array ( [certificate] => Array ( [code] => 14001 [$] => Interdit aux moins de 12 ans ) ) [poster] => AlloImage Object ( [imageIcon:AlloImage:private] => [imageBorder:AlloImage:private] => [imageSize:AlloImage:private] => [imageHost:AlloImage:private] => fr.web.img1.acsta.net [imagePath:AlloImage:private] => pictures/14/11/14/11/08/371396.jpg ) [trailer] => Array ( [name] => Bande-Annonce Cinquante Nuances de Grey [code] => 19549475 [href] => http://www.allocine.fr/blogvision/19549475 ) [dvdReleaseDate] => 2015-06-16 [bluRayReleaseDate] => 2015-06-16 [link] => Array ( [0] => Array ( [rel] => aco:web [name] => Cinquante Nuances de Grey [href] => http://www.allocine.fr/film/fichefilm_gen_cfilm=205450.html ) [1] => Array ( [rel] => aco:web_casting [name] => Casting Cinquante Nuances de Grey [href] => http://www.allocine.fr/film/fichefilm-205450/casting/ ) [2] => Array ( [rel] => aco:web_trivia [name] => Anecdotes Cinquante Nuances de Grey [href] => http://www.allocine.fr/film/fichefilm-205450/secrets-tournage/ ) [3] => Array ( [rel] => aco:web_showtimes [name] => S�ances Cinquante Nuances de Grey [href] => http://www.allocine.fr/seance/film-205450/ ) [4] => Array ( [rel] => aco:web_publicreviews [name] => Critiques Spectateurs Cinquante Nuances de Grey [href] => http://www.allocine.fr/film/fichefilm-205450/critiques/spectateurs/ ) [5] => Array ( [rel] => aco:web_pressreviews [name] => Critiques presse Cinquante Nuances de Grey [href] => http://www.allocine.fr/film/fichefilm-205450/critiques/presse/ ) [6] => Array ( [rel] => aco:web_shots [name] => Photos Cinquante Nuances de Grey [href] => http://www.allocine.fr/film/fichefilm-205450/photos/ ) [7] => Array ( [rel] => aco:web_trailers [name] => Bandes annonces Cinquante Nuances de Grey [href] => http://www.allocine.fr/videos/fichefilm-205450/toutes/ ) [8] => Array ( [rel] => aco:web_products [name] => Cinquante Nuances de Grey [href] => http://www.allocine.fr/film/fichefilm-205450/vod-dvd/ ) ) ) [/B]
 
My bad, bartosimpsonio is right, it's not JSON. Ok, extract the values you
need from the object and then save them in the database.

EDIT: It is YAML. Use this: https://code.google.com/p/php-yaml/ and the
yaml_parse function. You have to install the PHP extension though.
 
Last edited:
PHP is not my thing honestly. But Im trying my best.

Thanks for the answers. Now instead if installing YAML on my server, how can I extract those infos from the array ?

the
Code:
var_dump($movie->poster);

gives me

Code:
[h=2][SIZE=2]object(AlloImage)#306 (5) { ["imageIcon":"AlloImage":private]=> bool(false) ["imageBorder":"AlloImage":private]=> bool(false) ["imageSize":"AlloImage":private]=> bool(false) ["imageHost":"AlloImage":private]=> string(21) "fr.web.img1.acsta.net" ["imagePath":"AlloImage":private]=> string(34) "pictures/14/11/14/11/08/371396.jpg" }[/SIZE][/h]

So i guess I have to get the Image host + imagepath right ?

How do i pass those parameters for a echo or var_dump ?
 
People are giving you wrong advice. It isn't JSON or YAML, it is the default serialization provided with PHP. The error you are receiving upon 'unserializing' is a problem with storing it in the database, which makes it corrupt.
 
People are giving you wrong advice. It isn't JSON or YAML, it is the default serialization provided with PHP. The error you are receiving upon 'unserializing' is a problem with storing it in the database, which makes it corrupt.


I didn't store anything in the database, I'm trying to unserialize it directly after the API call.
 
Ok remove Spyc. Do var_dump($movies), paste in pastebin.com and reply with a link.
 
Hi

Make some change in code and everything working fine.
i made search movie name "XMEN" and get movie code 111543 and pass to get movie function and got result, i believe that when you passing movie code into get movie detail function it is char not int use type casting.
I upload code on my testing server i like to post URL here as you know i am not a donor so i can't post URL here if you want help please let me know.
Cheers
 
Back
Top
AdBlock Detected

We get it, advertisements are annoying!

Sure, ad-blocking software does a great job at blocking ads, but it also blocks useful features and essential functions on BlackHatWorld and other forums. These functions are unrelated to ads, such as internal links and images. For the best site experience please disable your AdBlocker.

I've Disabled AdBlock