执行此操作时,我不断收到此错误:
<?php
$info = $_POST['mname'];
$info = ucwords($info);
// Make a MySQL Connection
mysql_connect("localhost", "user", "password") or die(mysql_error());
mysql_select_db("javadatest") or die(mysql_error());
// Get a specific result from the "example" table
$result = mysql_query("SELECT * FROM movieList
WHERE name = '$info'") or die(mysql_error());
// get the first (and hopefully only) entry from the result
$row = mysql_fetch_array( $result );
// Print out the contents of each row into a table
//echo $row['name']." ".$row['year']." ".$row['genre'];
echo "
<script language=javascript>
var jsvar;
jsvar = <?php echo $row['name'], $row['year'], $row['genre'];?>
function buy() {
window.location = \"https://www.paypal.com\";
alert(\"Thanks for shopping at Movie Store\");
}
var myWindow = window.open('', '', 'width = 300, height = 300);
myWindow.document.write(jsvar);
myWindow.document.write('<body>');
myWindow.document.write('<input type="button" value="Buy" onclick=/"buy()/">');
myWindow.document.write('</body>');
//myWindow.buy = buy;
</script>
";
?>
我试图通过将我的 javascript 代码放在我的 echo 语句中来在 php 文件中使用 javascript。我无法弄清楚我做错了什么。任何帮助,将不胜感激。