How to get object's values from object in php?

时间:2016-08-31 12:19:07

标签: php mysql

I am selecting one column from Member table. Now I want to get the value from this column. But when I try to get the value I am getting an exception as :

 <br />
<b>Notice</b>:  Trying to get property of non-object in
<b>C:\Program Files (x86)\Ampps\www\MLMapi\PurchaseProduct.php</b> on line
<b>54</b>
<br />

Code:

    $stmt = $dbConnection->prepare("select Member.sales_hold_fund from Member where member_id=?");
    $stmt->execute(array($member_id));
    $member = $stmt->fetch(PDO::FETCH_ASSOC);

        $fund = $member-> sales_hold_fund;// line54

        $sales_hold_fund = $fund + $amount;

I want to get the sales_hold_fund value from database and add the amount value to the sales_hold_fund.

member value :

 "Member": {
    "sales_hold_fund": "1000"
  }

Can anyone help please? Thank you..

1 个答案:

答案 0 :(得分:1)

try

 $fund = $member['sales_hold_fund'];