这是我的代码形式的数据添加到MySQL时,“网站无法处理请求”:我在尝试使用PHP
<?php
$link = mysqli_connect("localhost", "user", "pw", "dbname");
//if(mysqli_connect_error()){
//echo "There was an error";
//}else{
//echo "Database connection successful"; }
// Check connection
if ($link->connect_error) {
die("Connection failed: " . $link->connect_error);
}
//The problem started after I added the following code
mysqli_query($link,"INSERT INTO posts (name, email, phonenumber, billAddress, billCity, billProvince, billPC)
VALUES ('$_POST[name]', '$_POST[email]', '$_POST[phonenumber]', '$_POST[billAddress]', '$_POST[billCity]', '$_POST[billProvince]', '$_POST[billPC]')";
?>
添加代码的最后位之前,这是工作的罚款。在我添加代码并点击刷新后,我收到http 500错误。它还表示我的网页无法正常工作,我的网页目前无法处理请求。
我不确定这是我的编码问题还是别的。请提前帮助并感谢您。
不是你目前的问题,但要意识到你允许任何人在数据库查询中注入任何他们想要的东西。请了解参数,不要再次使用这种类型的代码。它也可能显示实际的错误。 –