MrIntel Posted October 18, 2013 Share Posted October 18, 2013 if($balance >= $cashout){ $mysqli->query("UPDATE balances SET balance=balance-$balance WHERE email='$email'"); $balanceQ = $mysqli->query("SELECT balance FROM balances WHERE email='$email'"); //we check again to prevent race attacks if($balanceQ->fetch_row() >= 0){ $url = "https://inputs.io/api?key=$apiKey&action=send&address=&amount=¬e=&pin=$apiPin" . urlencode($cashoutMessage . " | MyFaucet Powered") . "&address=" . urlencode($email) . "&amount=" . ($balance / 100000000); $response = file_get_contents($url); if($response[0] == "["){ //success echo "<div class='alert alert-success'>Successful cashout to $email - enjoy!</div>"; } else { echo "<div class='alert alert-error'>An error has occured - $response</div>"; if($response == "NO_BALANCE"){ echo "<div class='alert alert-error'>The site does not have enough coins to pay out!</div>"; $mysqli->query("UPDATE balances SET balance=balance+$balance WHERE email='$email'"); Im having problems when people go cashout and they get error page i think the problem is $url but i dont know if you want to find out the api go here https://inputs.io/api and head to send transactions so from there i dont know what else to do. Quote Link to comment https://forums.phpfreaks.com/topic/283074-php-help/ Share on other sites More sharing options...
mac_gyver Posted October 18, 2013 Share Posted October 18, 2013 (edited) this code seems familiar. someone else just posted problems with the same. a) you need to have php's error_reporting set to E_ALL and display_errors set to ON when debugging php code to get php to help you by reporting and displaying the errors it detects. b) the ->fetch_row() method, unless you have written your own database class, returns an array. comparing an array with an integer isn't going to produce the result you expect. you need to reference the zeroth element of the fetched array to access the value the query selected. assigning the fetched row to a php variable, then referencing the zeroth element of that array in the if() comparison would be the best method as it will work regardless of php version (the latest php5.4 has a short-cut method, but will break on earlier php versions.) c) if the code setting $balance, about 10 lines above the code you posted, is also just using a ->fetch_xxxxx() method, without referencing the correct element in the fetched array to access the balance value, the comparisons using $balance are also not working. Edited October 18, 2013 by mac_gyver Quote Link to comment https://forums.phpfreaks.com/topic/283074-php-help/#findComment-1454390 Share on other sites More sharing options...
mac_gyver Posted October 18, 2013 Share Posted October 18, 2013 i back tracked to this script's site and the author of this script is using php5.4 syntax. removing the [0] that was on the ->fetch_xxxxx()[0] statements may have eliminated some error messages, but won't cause the script to work unless you add code that fetches/references the correct element of the arrays. you will need to go through all the code making modifications (or upgrade to at least php5.4.) the author is also using the short form of array syntax. this will need to be changed to the long/full array syntax (didn't php learn that putting in short-cuts wasn't a good idea.) Quote Link to comment https://forums.phpfreaks.com/topic/283074-php-help/#findComment-1454391 Share on other sites More sharing options...
MrIntel Posted October 18, 2013 Author Share Posted October 18, 2013 ok well do you know any free or paid hosting that offers php5.4. Quote Link to comment https://forums.phpfreaks.com/topic/283074-php-help/#findComment-1454395 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.