0

I'm inserting variables into database and all values get inserted in the fields with expection of one field (pic). i get this error

<b>Notice</b>:  Undefined property: stdClass::$pic in <b>C:\xampp\htdocs\work\app_ion\templates\index_files\addphoto_insert.php</b> on line <b>5</b><br />

JS

.controller("camera_controller",['$scope','$http','$cordovaCamera','$ionicLoading','$ionicPopup','$timeout','$location', function ($scope,$http,$cordovaCamera,$ionicLoading,$ionicPopup,$timeout,$location) {
    $scope.email=localStorage.getItem("email");
    $http.get('http://localhost/work/app_ion/templates/index_files/addphoto_grab.php?email='+$scope.email).success(function(data){
        console.log(JSON.stringify(data));
        $scope.grab=data;
        });
        $http.post("http://localhost/work/app_ion/templates/index_files/addphoto_insert.php",
        {'pic':$scope.pic,'email':$scope.item.email,'user_id':$scope.item.profile_id,'country':$scope.item.country,'fpage':$scope.item.fpage})
        .success(function(data,status,headers,config){
        console.log(data)

            });

HTML

 <div ng-controller="camera_controller" ng-repeat="item in grab">
        <form id="form1" name="form1" method="post">
       <input name="user_id" type="hidden" id="user_id" ng-model="item.profile_id" />
              <input name="country" type="hidden" id="country" ng-model="item.country" />
              <input name="fpage" type="hidden" id="fpage" ng-model="item.fpage" />
              <input name="pic" type="hidden" id="pic" ng-model="item.pic" />
              <input name="email" type="hidden" id="email" ng-model="item.email"  />

        </form>
        </div>

PHP

    <?php require_once('../../../Connections/work.php'); ?>
    <?php
    $data= json_decode(file_get_contents("php://input"));

    $pic= mysql_real_escape_string($data->pic);
    $email= mysql_real_escape_string($data->email);
    $user_id= mysql_real_escape_string($data->user_id);
    $country= mysql_real_escape_string($data->country);
    $fpage= mysql_real_escape_string($data->fpage);


mysql_query("INSERT INTO work.pp_change (`pic`,`email`,`user_id`,`country`,`fpage`)VALUES('".$pic."','".$email."','".$user_id."','".$country."','".$fpage."')");
    ?>

Any help with this error?

user6579134
  • 659
  • 3
  • 7
  • 28
  • Please read this about the deprecated `mysql_` functions: https://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php – Chris Aug 21 '16 at 21:30
  • What does `$data` contain? Try using `print_r` or `var_dump` to see. – Chris Aug 21 '16 at 21:46
  • you are using html `item.pic` and you post data `$scope.pic` could this related to your problem, try to use `$scope.item.pic` – Abdelrahman M. Allam Aug 21 '16 at 22:04
  • tried that but it didn't work too – user6579134 Aug 22 '16 at 07:37
  • @user6579134, "didn't work" isn't very helpful. Did you follow my suggestion of inspecting `$data` with `print_r` or `var_dump`? What does it contain? – Chris Aug 22 '16 at 12:20
  • when i use var_dump i get - bool(true) and print_r i get - 1 – user6579134 Aug 22 '16 at 14:10
  • @user6579134, if `$data` is just `true` it sounds like maybe your input doesn't contain what you think it does. What do you think should be the next step? – Chris Aug 22 '16 at 16:18
  • yeah, what you are saying its true, it was sending empty values. please can you look into this question for me http://stackoverflow.com/questions/39074996/infinite-scrolling-with-angularjs-and-php – user6579134 Aug 22 '16 at 16:59

0 Answers0