Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: Anonymous on July 20, 2011, 04:49:37 PM



Title: [FIXED] PHP RPC code spits out question marks and then dosent do anything.
Post by: Anonymous on July 20, 2011, 04:49:37 PM
Hi,
I have the following code below that is designed to send bitcoins to a certain address from php, using json rpc in php.
Code:
<?php
//send bitcoins
require "jsonRPCClient.php";

 
  
$bitcoin = new jsonRPCClient('http://username:password@127.0.0.1:8332/');
 
  
$bitcoin->sendtoaddress("1KxMF3DbtCu7DqXr5FUeG52U14vm8zyZwE 0.01");
?>

But my code always spits out:
Code:
 "?????????????????????????????????????????????????????????????????????????????????????????????????E??????"

I also tried
Code:
<?php
//send bitcoins
require "jsonRPCClient.php";

 
  
$bitcoin = new jsonRPCClient('http://username:password@127.0.0.1:8332/');
 
  
$bitcoin->sendtoaddress("1KxMF3DbtCu7DqXr5FUeG52U14vm8zyZwE"0.01);
?>

But still get the same output. What is going on, and how can I fix it.


Title: Re: PHP RPC code spits out question marks and then dosent do anything.
Post by: Anonymous on July 20, 2011, 10:18:45 PM
Hi,
I have the following code below that is designed to send bitcoins to a certain address from php, using json rpc in php.
Code:
<?php
//send bitcoins
require "jsonRPCClient.php";

 
  
$bitcoin = new jsonRPCClient('http://username:password@127.0.0.1:8332/');
 
  
$bitcoin->sendtoaddress("1KxMF3DbtCu7DqXr5FUeG52U14vm8zyZwE 0.01");
?>

But my code always spits out:
Code:
 "?????????????????????????????????????????????????????????????????????????????????????????????????E??????"

I also tried
Code:
<?php
//send bitcoins
require "jsonRPCClient.php";

 
  
$bitcoin = new jsonRPCClient('http://username:password@127.0.0.1:8332/');
 
  
$bitcoin->sendtoaddress("1KxMF3DbtCu7DqXr5FUeG52U14vm8zyZwE"0.01);
?>

But still get the same output. What is going on, and how can I fix it.

Doesn't anyone know what is going on? (:


Title: Re: PHP RPC code spits out question marks and then dosent do anything.
Post by: drawoc on July 21, 2011, 05:11:36 AM
I don't have a clue what's wrong, but I'd just like to point out that your second example is more correct than the first.

Maybe if you simplified it even more it would help track down the problem? Instead of trying to send something, just:
print_r($bitcoin->getinfo());


Title: Re: PHP RPC code spits out question marks and then dosent do anything.
Post by: Anonymous on July 21, 2011, 05:36:04 AM
I don't have a clue what's wrong, but I'd just like to point out that your second example is more correct than the first.

Maybe if you simplified it even more it would help track down the problem? Instead of trying to send something, just:
print_r($bitcoin->getinfo());

I rewrote the code, and it works now, I do not know what may have been the problem, but it works now after I started fresh... You were right, the second example was correct. Thanks for responding...


Title: Re: PHP RPC code spits out question marks and then dosent do anything.
Post by: drawoc on July 21, 2011, 06:23:12 PM
I rewrote the code, and it works now, I do not know what may have been the problem, but it works now after I started fresh... You were right, the second example was correct. Thanks for responding...

Glad you've got this working now.


Title: Re: [FIXED] PHP RPC code spits out question marks and then dosent do anything.
Post by: Anonymous on August 12, 2011, 02:12:22 AM
Figured it out. My php was the problem. I saved the file with UTF-8 encoding, but I really should have saved it with UTF-16 encoding. I found this out when I wrote another php script for an unrelated project, and I got the same error. It was only on my mac. This fix works every time. Sorry to bother bitcoin about this  :)


Title: Re: [FIXED] PHP RPC code spits out question marks and then dosent do anything.
Post by: Inaba on August 13, 2011, 10:43:41 PM
I thought Macs "Just Work?"



Title: Re: [FIXED] PHP RPC code spits out question marks and then dosent do anything.
Post by: Anonymous on August 13, 2011, 10:48:47 PM
I thought Macs "Just Work?"


HA! Yah Right. If I had bitnickel every time I broke that phrase wide open, then I would be a millionaire