Log in

View Full Version : Array Inserts null Values in Database



mutago
07-03-2015, 04:03 AM
Array Inserts null Values in Database

I have the following Arrays, but it keeps inserting null values into database whenever the script is run




stdClass Object
(
[id] => 3341234
[id_str] => 33414123
[email] => Chi@gmail.com
[screen_name] => chibaco
[location] =>
[description] =>
[url] =>
[entities] => stdClass Object
(
[description] => stdClass Object
(
[urls] => Array
(
)

)

)

[protected] =>
[followers_count] => 8
[friends_count] => 41
[listed_count] => 0
[created_at] => Mon Jun 22 14:59:08 +0000 2015
[favourites_count] => 0
[utc_offset] =>
[time_zone] =>
[geo_enabled] =>
[verified] =>
[statuses_count] => 0
[lang] => en
[contributors_enabled] =>
[is_translator] =>
[is_translation_enabled] =>
[profile_background_color] => C0DEED
[profile_background_image_url] => http://abs.twimg.com/images/themes/theme1/bg.png
[profile_background_image_url_https] => https://abs.twimg.com/images/themes/theme1/bg.png
[profile_background_tile] =>
[profile_image_url] => http://pbs.twimg.com/profile_images/612999068701335552/VIbF69MX_normal.jpg
[profile_image_url_https] => https://pbs.twimg.com/profile_images/612999068701335552/VIbF69MX_normal.jpg
[profile_link_color] => 0084B4
[profile_sidebar_border_color] => C0DEED
[profile_sidebar_fill_color] => DDEEF6
[profile_text_color] => 333333
[profile_use_background_image] => 1
[has_extended_profile] =>
[default_profile] => 1
[default_profile_image] =>
[following] =>
[follow_request_sent] =>
[notifications] =>
)



my database is as follow






foreach ($content as $value) {


require('connect.php');


$statement= $db->prepare('INSERT INTO users(email,username,background_pic,pic)
values
(:email,:username,:background_pic,:pic)');

$statement->execute(array(
':email' => $value['email'],
':username' =>$value['name],
':background_pic' =>$value['profile_background_image_url_https'],
':pic' =>$value['profile_image_url'],
));

}