Bitcoin Forum
May 03, 2024, 06:22:10 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: « 1 [2]  All
  Print  
Author Topic: Question for the php-heads...  (Read 1411 times)
payb.tc
Hero Member
*****
Offline Offline

Activity: 812
Merit: 1000



View Profile
February 14, 2013, 03:41:28 AM
 #21

Aah, the joys of PHP and echo'ing SQL statements carefully crafted by hand Cheesy

yeah these days i'm more likely to be using codeigniter's $db->last_query() function after having it constructed for me Cheesy
1714717330
Hero Member
*
Offline Offline

Posts: 1714717330

View Profile Personal Message (Offline)

Ignore
1714717330
Reply with quote  #2

1714717330
Report to moderator
1714717330
Hero Member
*
Offline Offline

Posts: 1714717330

View Profile Personal Message (Offline)

Ignore
1714717330
Reply with quote  #2

1714717330
Report to moderator
1714717330
Hero Member
*
Offline Offline

Posts: 1714717330

View Profile Personal Message (Offline)

Ignore
1714717330
Reply with quote  #2

1714717330
Report to moderator
Even in the event that an attacker gains more than 50% of the network's computational power, only transactions sent by the attacker could be reversed or double-spent. The network would not be destroyed.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
Herodes
Hero Member
*****
Offline Offline

Activity: 868
Merit: 1000


View Profile
February 14, 2013, 03:43:29 AM
 #22

Not sure what kind of tools you use to develop, but I just set up vim with xdebug on my personal development machine, and it works wonders:
https://bitcointalk.org/index.php?topic=143923.0

I had an issue where some queries to get the current bitcoin price didn't work. So the usual method would be to make echo statements, and see where things went wrong, but then I installed this, and now I can step into functions, and execute code line by line, yay. I found the error I was chasing immediately, instead of using 30 minutes with echo statements. Smiley
c4n10 (OP)
Sr. Member
****
Offline Offline

Activity: 294
Merit: 250



View Profile
February 14, 2013, 03:48:08 AM
 #23

Not sure what kind of tools you use to develop, but I just set up vim with xdebug on my personal development machine, and it works wonders:
https://bitcointalk.org/index.php?topic=143923.0

I had an issue where some queries to get the current bitcoin price didn't work. So the usual method would be to make echo statements, and see where things went wrong, but then I installed this, and now I can step into functions, and execute code line by line, yay. I found the error I was chasing immediately, instead of using 30 minutes with echo statements. Smiley

I've never really used vim much, wasn't aware of the xdebug function, I always just code/edit in nano but sounds like vim might be worth taking a look at...
Herodes
Hero Member
*****
Offline Offline

Activity: 868
Merit: 1000


View Profile
February 14, 2013, 04:07:37 AM
 #24

Not sure what kind of tools you use to develop, but I just set up vim with xdebug on my personal development machine, and it works wonders:
https://bitcointalk.org/index.php?topic=143923.0

I had an issue where some queries to get the current bitcoin price didn't work. So the usual method would be to make echo statements, and see where things went wrong, but then I installed this, and now I can step into functions, and execute code line by line, yay. I found the error I was chasing immediately, instead of using 30 minutes with echo statements. Smiley

I've never really used vim much, wasn't aware of the xdebug function, I always just code/edit in nano but sounds like vim might be worth taking a look at...

Vim has a very steep learning code, but you can do all kinds of awsome things with it, and that's not just for the showoff factor, but also for the practical factor. The cool thing is that there's no menus, no nothing on your screen, so people looking at you will think you're some kind of wizzard. Keeping a cheat sheet near the computer or on the computer is a nice thing. I am sure there's a lot of beginners guides. There's a lot of nice shortcuts that let you perform magic. You can do block editing, ie. vertical editing, you can make macros etc. and there exist a lot of plugins, with ctags you can even get autocomplete. So for the long run it rocks. Once you start mastering it, you will never go back.

payb.tc
Hero Member
*****
Offline Offline

Activity: 812
Merit: 1000



View Profile
February 14, 2013, 04:39:54 AM
 #25

not that netbeans is perfect, but you can use xdebug in that no problem, you don't have to use vim
c4n10 (OP)
Sr. Member
****
Offline Offline

Activity: 294
Merit: 250



View Profile
February 14, 2013, 07:08:18 AM
 #26

Alright, I have this code:

Code:
<?php
require '../htdocs/config.php';
require 
'../util.php';

function 
update_req($reqid$status)
{
    
$query "
        UPDATE requests
        SET status='
$status'
        WHERE
            reqid='
$reqid'
            AND curr_type='RUC'
        "
;
    
do_query($query);
}

$query "
    SELECT
        requests.reqid AS reqid,
        uid,
        amount,
        addy
    FROM requests
    JOIN rucoin_requests
    ON requests.reqid=rucoin_requests.reqid
    WHERE
        req_type='WITHDR'
        AND amount > 0
        AND status='VERIFY'
        AND curr_type='RUC'
    "
;
$result do_query($query);
$rucoin connect_rucoin();
while (
$row mysql_fetch_assoc($result)) {
    
$reqid $row['reqid'];
    
$uid $row['uid'];
    
$amount $row['amount'];
    
$addy $row['addy'];

    if  (
$rucoin->getbalance('') >= 0)
    {
        
update_req($reqid'PROCES');
        
$rucoin->sendfrom(''$addy$amount);
        
update_req($reqid'FINAL');
    }
}
?>

And it is working perfectly all the way up to:

Code:
$rucoin->sendfrom('', $addy, $amount);

I believe I have a syntax error being fed to the jsonRPCClient as I know the $addy and $amount are both returning correct values, I have tested issuing the command by hand to rucoind so I know it supports the "sendfrom" function and is accessible yet I am receiving an HTTP 500 error from rucoind.

I am using the "$rucoin = connect_rucoin" function in various places to send calls to rucoind and retrieve information, all without error, but this last thing just does not seem to want to work.

Anyone have any ideas...?
payb.tc
Hero Member
*****
Offline Offline

Activity: 812
Merit: 1000



View Profile
February 14, 2013, 09:35:04 AM
 #27

Alright, I have this code:

Code:
<?php
require '../htdocs/config.php';
require 
'../util.php';

function 
update_req($reqid$status)
{
    
$query "
        UPDATE requests
        SET status='
$status'
        WHERE
            reqid='
$reqid'
            AND curr_type='RUC'
        "
;
    
do_query($query);
}

$query "
    SELECT
        requests.reqid AS reqid,
        uid,
        amount,
        addy
    FROM requests
    JOIN rucoin_requests
    ON requests.reqid=rucoin_requests.reqid
    WHERE
        req_type='WITHDR'
        AND amount > 0
        AND status='VERIFY'
        AND curr_type='RUC'
    "
;
$result do_query($query);
$rucoin connect_rucoin();
while (
$row mysql_fetch_assoc($result)) {
    
$reqid $row['reqid'];
    
$uid $row['uid'];
    
$amount $row['amount'];
    
$addy $row['addy'];

    if  (
$rucoin->getbalance('') >= 0)
    {
        
update_req($reqid'PROCES');
        
$rucoin->sendfrom(''$addy$amount);
        
update_req($reqid'FINAL');
    }
}
?>

And it is working perfectly all the way up to:

Code:
$rucoin->sendfrom('', $addy, $amount);

I believe I have a syntax error being fed to the jsonRPCClient as I know the $addy and $amount are both returning correct values, I have tested issuing the command by hand to rucoind so I know it supports the "sendfrom" function and is accessible yet I am receiving an HTTP 500 error from rucoind.

I am using the "$rucoin = connect_rucoin" function in various places to send calls to rucoind and retrieve information, all without error, but this last thing just does not seem to want to work.

Anyone have any ideas...?

PHP can sometimes do weird things with variable types... try this and get back to us:

Code:
$rucoin->sendfrom('', $addy, (float) $amount);
c4n10 (OP)
Sr. Member
****
Offline Offline

Activity: 294
Merit: 250



View Profile
February 14, 2013, 12:40:30 PM
 #28

PHP can sometimes do weird things with variable types... try this and get back to us:

Code:
$rucoin->sendfrom('', $addy, (float) $amount);

Hmmm, I will have to give that a try sometime, was actually coming back to report that I got it working with:

Code:
$rucoin->sendfrom('', $addy, (double)$amount);
payb.tc
Hero Member
*****
Offline Offline

Activity: 812
Merit: 1000



View Profile
February 14, 2013, 12:56:04 PM
 #29

PHP can sometimes do weird things with variable types... try this and get back to us:

Code:
$rucoin->sendfrom('', $addy, (float) $amount);

Hmmm, I will have to give that a try sometime, was actually coming back to report that I got it working with:

Code:
$rucoin->sendfrom('', $addy, (double)$amount);

just as good
Pages: « 1 [2]  All
  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!