Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9179801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:53:28+00:00 2026-06-17T17:53:28+00:00

I have created a PHP connection to my database and made the following query:

  • 0

I have created a PHP connection to my database and made the following query:

$taxRates = array();
while($row = mysql_fetch_assoc($result)) {
    $taxRates[] = $row['mar_tax_rate'];
}

I then encoded the result as follows:

$jsonobj = json_encode($taxRates, JSON_NUMERIC_CHECK);
echo "This is jsonobj:<br>" . $jsonobj . "<br>";

Which returns:

This is jsonobj:
[0,0.35,0.35,0.35,0.35,0.35,0.35,0.35,0.35]

The problem that I am having is this. When I try to echo these results into JS, my result is coming back empty (as far as I can see) — not an empty array, just nothing. This is how I am trying to feed the result into JS:

data:[<?php echo $jsonobj; ?>]

Which returns:

data:

I have tried to alert the PHP variable using

alert("<?php echo $jsonobj; ?>");  

which produces an alert, but is also empty.

Any thoughts?

Here is the full code:

<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<script type="text/javascript" src="includes/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="includes/js/highcharts.2.3.2.js"></script>
<script type="text/javascript" src="includes/js/highstock.src.js"></script> 

<script type="text/javascript">
$(document).ready(function() {
  drawChart();
});

function drawChart() {

alert("<?php echo join($jsonobj); ?>");
var chart = new Highcharts.Chart({
    chart: {
        renderTo: 'chart',
        type: 'column',
    },      
    credits: {
        enabled: false
    },  
    series: [{
        data:[<?php echo $jsonobj; ?>]
    }]
});
};
</script>

</head>

<body>

<button style="height:100px; width:300px;" onclick="drawChart();">Redraw the Chart</button><br />

<div id="chart"></div>

<?php 
$link = mysql_connect('url', 'username', 'password'); 
if (!$link) { 
    die('Could not connect: ' . mysql_error()); 
} 
//mysql_close($link);

$db_selected = mysql_select_db('bloch',$link); 
if (!$db_selected) {
    die ('Can\'t use Bloch Database : ' . mysql_error());
}

$result = mysql_query('SELECT mar_tax_rate from bloch.bloch_deficit');
if (!$result) {
    die('Invalid query: ' . mysql_error());
}

$taxRates = array();
while($row = mysql_fetch_assoc($result)) {
    $taxRates[] = $row['mar_tax_rate'];
}

$jsonobj = json_encode($taxRates, JSON_NUMERIC_CHECK);
echo "This is jsonobj:<br>" . $jsonobj . "<br>";
?>

</body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T17:53:29+00:00Added an answer on June 17, 2026 at 5:53 pm

    Your variable isn’t being defined before you try and put it in to your HTML. Create the variable with what you need before your HTML in order to get it to the page correctly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a PHP code to echo the following div <div id=main_catsel> <select
I develop web applications with PHP. I have many classes using a database connection.
I need to connect to a remote MySQL database and have created the following
I have created a file name database.php and here is it's content <?php #Start
I have created a 'db.php' file where I make a connection to my db:
I have created PHP GD image for captcha, file called image.php each time it
I am noob with php so pardon my ignorance. I have created php form
I have created a php/mysql based chat page.It is like gmail chat.once i click
I have created a PHP script and I am lacking to extract the primary
I have created a php table like so: echo <table border = '0' cellpadding

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.