开发者

PDO Request Causing 500 Internal Server Error

This PDO request is not welcomed by开发者_如何学Python my server for some reason. It makes the server throw a 500 Internal Server Error. All of my other PHP files are working fine and I haven't changed any server settings. Strangely though, It seems that when I comment out the line that binds the variable $u, it does not give a 500 error. I am perplexed.

<?php

$u=$_GET["u"];

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form2")) {
$amount = isset($_POST['amount']) ? $_POST['amount'] : null;
if (null != $amount) {

$user = 'username';
$pass = 'password';
$pdo = new PDO('mysql:host=localhost', $user, $pass);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
session_start();
$tablename = $_SESSION['MM_Username'];
$query = sprintf("UPDATE `%s` SET `stock` = :amount WHERE `itemname` = :u", $tablename);
$stmt = $pdo->prepare($query);
$stmt->bindParam('u', $u);
$stmt->bindParam('amount', $amount);
$stmt->execute();
}
}

?>


Your error log will have an error message in it that will tell you your problem.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜