I need to pass variables defined in PHP to a javascript function. The JS function needs to be called with a button onclick event.
<button type="button" style="width: 70px;" class="btn btn-light btn-sm Center"
onclick="<?php echo '<script>purchase('{$user}','{$painting1_Title}','200')</script>'?>">Purchase</button>
I have tried different connotations of single and double quotes but am getting parsing errors:
Parse error: syntax error, unexpected '','' (T_CONSTANT_ENCAPSED_STRING), expecting ',' or ';' in /Applications/XAMPP/xamppfiles/htdocs/ProjectWebsite/Mainpage2.php on line 303
So my question is how to call a javascript function with PHP inside a onclick event?