tags:

views:

26

answers:

1

This PDO request is not welcomed by 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();
}
}

?>
+1  A: 

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

Andy Lester