<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
", 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);
// }
?>
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
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;?>'