0
<script>
        $(document).ready(function(){
                 var oMain = new CMain({
                                win_occurrence:30,        //WIN    PERCENTAGE.SET A VALUE FROM 0 TO 100.
                                slot_cash: 2000000,          //THIS IS THE CURRENT SLOT CASH AMOUNT. THE GAME CHECKS IF THERE IS AVAILABLE CASH FOR WINNINGS. THIS SHOULD BE BALANCE OF MY OVERALL BTC ACCOUNT.
                                min_reel_loop:2,          //NUMBER OF REEL LOOPS BEFORE SLOT STOPS  
                                reel_delay: 6,            //NUMBER OF FRAMES TO DELAY THE REELS THAT START AFTER THE FIRST ONE
                                time_show_win:2000,       //DURATION IN MILLISECONDS OF THE WINNING COMBO SHOWING
                                time_show_all_wins: 2000, //DURATION IN MILLISECONDS OF ALL WINNING COMBO
                                money:<?php include 'getbtcbalance.php'; echo $btcbalance;?> ,               //STARING CREDIT FOR THE USER - THIS IS GOING TO BE AN ECHO OF USER ADDRESS BALANCE.. So 'getbalance of addressofsessionidvariable'
                                ad_show_counter:3    

(after this isnt necessary to see as works fine)

As you can see, I am trying to get the 'money:' part to be a php variable called $btcbalance from the file getbtcbalance.php.

The php variable $btcbalance works fine on getbtcbalance.php and can be echoed to display the correct balance, I just need to make it work in the js script.

What I did above doesnt work, I just left it there so you can see what I'm trying to do.

Hope someone can help.

EDIT:

Attached as requested is the content of getbtcbalance.php:

<?php

    // Getting BTC address from database by using a post function 'selecting row of session username' 
//Set btc address as a ssession variable so that it can be used for topup
include_once 'blockconfig.php';
session_start();

$connect=mysqli_connect('localhost', 'root', 'PASSWORD') or die(mysqli_error());
mysqli_select_db($connect, 'test6') or die("Cannot select database");

$sessionusername = $_SESSION['username'];
$res2 = mysqli_query($connect, "SELECT * FROM test WHERE username='$sessionusername'");
if (!$res2) {
printf("Error: %s\n", mysqli_error($connect));
exit();
}
$row=mysqli_fetch_array($res2);

$bitty = $row['btcaddress'];
$_SESSION['btcaddress'] = $bitty;
$btcbalancedetails = $block_io->get_address_balance($bitty);
$btcbalance = "".$btcbalancedetails->data->available_balance."";
// Do below if you need to echo the address on this page, or you can copy / paste it onto another page to echo the btc address

// if (isset($bitty)){

//   echo $sessionusername."'s BTC address for TOP-UP: ".$bitty;}
//    else { 
//            echo mysqli_error($connect);
// }


?>
4
  • And what exactly is the problem? Are you getting an error on the console? is $btcbalance a string? if so then you need to surround it in quotes so that it is treated as such Commented Jul 14, 2016 at 14:11
  • Please share more information, like the source of the generated page (in the browser) or codes inside getbtcbalance.php. This question is a little unclear. Commented Jul 14, 2016 at 14:11
  • Please attach content of getbtcbalance.php file as well Commented Jul 14, 2016 at 14:11
  • Attached the relevant content :) Commented Jul 14, 2016 at 21:30

2 Answers 2

1

You can include php file before html code then you use php file variable(s).

<?php include 'getbtcbalance.php';?>
<script>
        $(document).ready(function(){
                 var oMain = new CMain({
                                win_occurrence:30,        //WIN    PERCENTAGE.SET A VALUE FROM 0 TO 100.
                                slot_cash: 2000000,          //THIS IS THE CURRENT SLOT CASH AMOUNT. THE GAME CHECKS IF THERE IS AVAILABLE CASH FOR WINNINGS. THIS SHOULD BE BALANCE OF MY OVERALL BTC ACCOUNT.
                                min_reel_loop:2,          //NUMBER OF REEL LOOPS BEFORE SLOT STOPS  
                                reel_delay: 6,            //NUMBER OF FRAMES TO DELAY THE REELS THAT START AFTER THE FIRST ONE
                                time_show_win:2000,       //DURATION IN MILLISECONDS OF THE WINNING COMBO SHOWING
                                time_show_all_wins: 2000, //DURATION IN MILLISECONDS OF ALL WINNING COMBO
                                money:<?php echo $btcbalance;?> ,               //STARING CREDIT FOR THE USER - THIS IS GOING TO BE AN ECHO OF USER ADDRESS BALANCE.. So 'getbalance of addressofsessionidvariable'
                                ad_show_counter:3    
Sign up to request clarification or add additional context in comments.

Comments

0

you are echoing the balance at the time of page load, are you sure it will be same after your page loaded.

it's the constant value then try this-

money:'<?php echo $btcbalance;?>' 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.