Bitcoin Forum
May 07, 2024, 12:07:20 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: 【SOLVED】PHP error help!  (Read 1090 times)
maomao (OP)
Member
**
Offline Offline

Activity: 117
Merit: 10

Not only FUD :)


View Profile
February 13, 2013, 03:25:40 AM
Last edit: February 13, 2013, 04:48:42 PM by maomao
 #1

get this warning in my error logs and wanted to know how to correct this issues in my code.

Warning: PHP Notice: Undefined property: stdClass::$balance in script.php on line 33





$balance = $json->{'balance'} / 100000000; // line 33

quarkchain.io
In order to achieve higher forum ranks, you need both activity points and merit points.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715083640
Hero Member
*
Offline Offline

Posts: 1715083640

View Profile Personal Message (Offline)

Ignore
1715083640
Reply with quote  #2

1715083640
Report to moderator
1715083640
Hero Member
*
Offline Offline

Posts: 1715083640

View Profile Personal Message (Offline)

Ignore
1715083640
Reply with quote  #2

1715083640
Report to moderator
payb.tc
Hero Member
*****
Offline Offline

Activity: 812
Merit: 1000



View Profile
February 13, 2013, 03:36:46 AM
 #2

maomao, before line 33, can you

var_dump($json);

...if possible, pasting the whole script here might help.
BCB
CTG
VIP
Legendary
*
Offline Offline

Activity: 1078
Merit: 1002


BCJ


View Profile
February 13, 2013, 03:53:54 AM
 #3

did you include the library you are referencing or is the path correct?
payb.tc
Hero Member
*****
Offline Offline

Activity: 812
Merit: 1000



View Profile
February 13, 2013, 04:00:49 AM
 #4

have you tried this by the way:

$balance = $json->balance / 100000000; // line 33

i'm not familiar with the script you're using... did you copy it from somewhere, or come up with that line yourself?


without further detail, it appears to me that the line you're using is looking inside the $json object for a property or method called $balance and then using the value of $balance to look for a further property or method of $json.

eg.

class jsonClass {
     $balance = 'mybalancevar';
     $mybalancevar = 33;
}

in this case, $json->{'balance'} would equal 33; while $json->balance would be a string: mybalancevar
maomao (OP)
Member
**
Offline Offline

Activity: 117
Merit: 10

Not only FUD :)


View Profile
February 13, 2013, 06:16:14 AM
 #5

function check_balance()
{
   

   
      $jsonurl = "https://blockchain.info/merchant/".$GLOBALS['user']."/balance?password=".$GLOBALS['password'];
      $json = file_get_contents($jsonurl,0,null,null);
      $json = json_decode($json);
      
       $balance = $json->balance/ 100000000;
      
      
   
   return $balance;
}

quarkchain.io
payb.tc
Hero Member
*****
Offline Offline

Activity: 812
Merit: 1000



View Profile
February 13, 2013, 09:19:37 AM
 #6

function check_balance()
{
   

   
      $jsonurl = "https://blockchain.info/merchant/".$GLOBALS['user']."/balance?password=".$GLOBALS['password'];
      $json = file_get_contents($jsonurl,0,null,null);

echo '<pre>$json = ' . $json . '<br/><br/>';

      $json = json_decode($json);

print_r($json);
echo '</pre>';


       $balance = $json->balance/ 100000000;
      
      
   
   return $balance;
}


let's see what's in that $json var first, so we know why the balance thing is throwing an error
maomao (OP)
Member
**
Offline Offline

Activity: 117
Merit: 10

Not only FUD :)


View Profile
February 13, 2013, 10:23:27 AM
 #7

Thank you.  The reason is that there are special characters in my password.

quarkchain.io
ingrownpocket
Legendary
*
Offline Offline

Activity: 952
Merit: 1000


View Profile
February 13, 2013, 10:30:42 AM
 #8

Glad it was 【SLOVED】 Grin
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!