0

I am trying to get a value assigning in Javascript variable directly using PHP-JSON as following

var productVatValue = <?php echo json_encode($productVatValue) ?>; 

I have also tried solution

var productVatValue = <?php echo json_encode($productVatValue, JSON_HEX_TAG); ?>; 

from the post here How do I pass variables and data from PHP to JavaScript? but same error " parsing error unexpected token < " is showing on the line -- how I can solve the error?

alexvan
  • 53
  • 6
  • 1
    What exactly is the error message and which file and line of code does it refer to? Is your PHP actually running / being parsed for this file? If you view the page source (as in right-click -> _"View page source"_), what does it look like? – Phil Aug 12 '20 at 00:56
  • @Phil, Yes, I can get the data from PHP and here is the error: " parsing error unexpected token < " page here is the code on php { [code] query($sqlvat); if($resultVat->num_rows > 0) { $row = $resultVat->fetch_array(); $productVatValue=$row[0]; } // if num_rows //$connect->close(); echo json_encode($productVatValue); // original was $row, it gets the variable properly //echo $productVatValue; ?> [/code] } – alexvan Aug 12 '20 at 01:05

0 Answers0