获取Btc事务哈希并发送到mysql

时间:2015-05-24 18:00:32

标签: mysql api blockchain

你好,从昨天开始我试图在区块链上获取事务哈希发送许多api并发送到mysql但它不起作用。我把插入在mysql $ txid,但它给出错误的结果,例如“2147483647”我非常感谢任何帮助。以下是我的代码。

<p>$guid=&quot;***********&quot;;
$firstpassword=&quot;**********&quot;;
$secondpassword=&quot;**************&quot;;
$amounta=&quot;3599&quot;;
$amountb=&quot;2000&quot;;
$amountc=&quot;2000&quot;;
$addressa=&quot;********&quot;;
$addressb=&quot;***********&quot;;
$addressc=&quot;******&quot;;
$recipients=urlencode('{
&quot;'.$addressa.'&quot;: '.$amounta.',
&quot;'.$addressb.'&quot;: '.$amountb.',
&quot;'.$addressc.'&quot;: '.$amountc.'
}');
$json_url = 
&quot;https://blockchain.info/pt/merchant/$guid/sendmany?password=******&amp;second_password=********&amp;recipients=$recipients&amp;note=********&quot;;

$json_data = file_get_contents($json_url);

$json_feed = json_decode($json_data);

$message = $json_feed-&gt;message;
$txid = $json_feed-&gt;tx_hash;
$tx = &quot;$txid&quot;;

$servername = &quot;localhost&quot;;
$username = &quot;******&quot;;
$password = &quot;*******&quot;;
$dbname = &quot;*****&quot;;

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn-&gt;connect_error) {
die(&quot;Connection failed: &quot; . $conn-&gt;connect_error);
}
$<font color="#FF0000">sql = &quot;INSERT INTO payments (user_id, transaction_hash, 
payment, date)
VALUES ('5331', '$txid', '4', now())&quot;;
if ($conn-&gt;query($sql) === TRUE) {
echo &quot;New record created successfully&quot;;
} else {
echo &quot;Error: &quot; . $sql . &quot;&lt;br&gt;&quot; . $conn-&gt;error;<br>
}

$conn-&gt;close();
?&gt; 

1 个答案:

答案 0 :(得分:0)

大声笑,抱歉scrypt工作得很好,问题是我将表设置为INT 11,所以我将其更改为vachar 255并且运行良好。

由于