[英]Why am I getting this 500-Internal Server Error
I am getting an POST 500 (Internal Server Error) on my website.我在我的网站上收到 POST 500(内部服务器错误)。
When testing on my local host i get no errors, only after publishing and running the site live do I get errors when trying to add product into cart.在我的本地主机上进行测试时,我没有收到任何错误,只有在发布并实时运行网站后,我才会在尝试将产品添加到购物车时出现错误。
In shop php file I have written ajax code for adding item into cart and passing data through ajax into action file for SQL query and this is working fine in localhost server but I'm getting error in live website.在商店 php 文件中,我编写了 ajax 代码,用于将项目添加到购物车中,并通过 ajax 将数据传递到 SQL 查询的操作文件中,这在 localhost 服务器中运行良好,但在实时网站中出现错误。 Please show me way how can I overcome this problem.
请告诉我如何克服这个问题。
This is my ajax code:这是我的ajax代码:
<script type="text/JavaScript">
$(document).ready(function(){
$(".addItemBtn").click(function(e){
e.preventDefault();
var $form =$(this).closest(".form-submit");
var pid=$form.find(".pid").val();
var pname=$form.find(".pname").val();
var pprice=$form.find(".pprice").val();
var pimage=$form.find(".pimage").val();
var pcode=$form.find(".pcode").val();
$.ajax({
url: 'action.php',
method: 'get',
data: {pid:pid,pname:pname,pprice:pprice,pimage:pimage,pcode:pcode},
success:function(response)
{
$("#message").html(response);
load_cart_item_number();
}
});
});
load_cart_item_number();
function load_cart_item_number()
{ $.ajax({
url: 'action.php',
method: 'get',
data: {cartItem:"cart_item"},
success:function(response){
$("#cart-item").html(response);
}
});
}
});
</script>
here is my second file action.php这是我的第二个文件 action.php
if (isset($_GET['pid'])) {
$pid=$_GET['pid'];
$pname=$_GET['pname'];
$pprice=$_GET['pprice'];
$pimage=$_GET['pimage'];
$pcode=$_GET['pcode'];
$userid= $_SESSION["id"];
$pqty=1;
$sql = "SELECT product_id FROM cart WHERE user_id=$userid and product_id = ?";
$stmt = mysqli_prepare($link, $sql);
mysqli_stmt_bind_param($stmt, "s", $pcode);
mysqli_stmt_execute($stmt);
$res=$stmt->get_result();
$row=$res->fetch_assoc();
$code=$row['product_id'];
if(!$code)
{
$query="INSERT INTO `cart`(`user_id`,`product_name`, `product_price`, `product_image`, `qty`, `total_price`, `product_id`) VALUES (?,?,?,?,?,?,?)";
$stmt = mysqli_prepare($link, $query);
mysqli_stmt_bind_param($stmt, "isisiii",$userid,$pname, $pprice,$pimage,$pqty,$pprice,$pcode);
mysqli_stmt_execute($stmt);
echo "Added to Buy Card";
}
else{
echo "Already Added In Buy Card";
}
}
Inside your server there might be some issues.您的服务器内部可能存在一些问题。 Find and try to solve that.
找到并尝试解决这个问题。 Your browser error log is disabled.
您的浏览器错误日志已禁用。 To enable and show error in browser you should use below code //travel insurance calculator customization
要在浏览器中启用和显示错误,您应该使用以下代码//旅行保险计算器定制
ini_set( 'display_errors', 1 );
ini_set( 'display_startup_errors', 1 );
error_reporting( E_ALL );
If you don't enable error to show in browser.如果您不启用错误显示在浏览器中。 then see your error log file in your base directory inside server.
然后在服务器内的基本目录中查看错误日志文件。 file name should be error.log or something else
文件名应该是error.log或其他
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.