可以在JavaScript 里使用PHP连接MySQL吗?
我现在的代码是这样的
<html>
<head>
<title>Untitled Document</title>
<script>
function test(){
<?php
$conn = mysql_connect("localhost", "username", "123123");
mysql_select_db("username", $conn);
mysql_query("INSERT INTO ChargerTogether (Chat) VALUES ('test')");
$result= mysql_query("SELECT *FROM ChargerTogether");
echo "<p> {$result} </p>>";
?>
}
</script>
</head>
<body>
<input type="button" onClick="javascript:test();">
</body>
</html>
但这样是错误的
我该怎样做呢
长着羽翼的赛姬
9 years, 8 months ago