Reputation: 83
I have the following php script snippet:
try{
$con = new PDO("mysql:host=$host;dbname=$databaseName;charset=utf8",$user,$pass);
$con->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$dat = $_REQUEST['dat'];
$poll = $dat[0];
$date = $dat[1];
$zip = $dat[2];
$answer = $dat[3];
$q = $con->prepare("INSERT INTO votes (poll_id, date, location, answers) VALUES (:poll, :date, :zip, :answer)");
$q->bindParam(':poll', $poll, PDO::PARAM_INT);
$q->bindParam(':date', $date, PDO::PARAM_STR);
$q->bindParam(':zip', $zip, PDO::PARAM_STR);
$q->bindParam(':answer', $answer, PDO::PARAM_STR);
if ($q->execute){
echo "worked";
} else {
echo "didn't work";
}
}catch(PDOException $e){
echo $e->getMessage();
}
Every time I try and run this script, I get an internal server error (500). There is no echo, no error message, nothing. When I remove the error handling, I get 200, but the "didn't work" message.
Please help!
EDIT: Added ini_set("display_errors",1); to top of page. Some reason 500 error no longer occurs, but still getting "didn't work".
Upvotes: 1
Views: 45