<?php
ini_set('default_charset', 'utf-8');
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "vsadb";
//----
$sbj = "";
$Qpos = "";

$qnatr = "";
$exmtyp = "";
$dt = "";
$yr = "";
$questn = "";
$qqd = "";
$chA = "";
$chB = "";
$chC = "";
$chD = "";
$resp = "";
$soln = "";
$btch = "";
$tps = "";
$qsttus = "";
$stMark = "";
$paragT ="";
$chC = "";
//----
//if (ctype_alpha($_POST['sbj'])) {}
$sbj = $_POST['sbj'];

	/*if (ctype_alpha($_POST['Qpos'])) {
$pos = $_POST['Qpos'];
}*/
$pos = intval($_POST['Qpos']); 

//if (ctype_alpha($_POST['questn'])) {}
  // $questn = $_POST['questn'];
   $questn = $_POST['qd'];

//if (ctype_alpha($_POST['qnatr'])) {}
$qnatr = $_POST['qnatr'];

//if (ctype_alpha($_POST['exmtyp'])) {}
$exmtyp = $_POST['exmtyp'];

//if (ctype_alpha($_POST['dt'])) {}
$dt = $_POST['dt'];

//if (ctype_alpha($_POST['yr'])) {}
$yr = $_POST['yr'];


//if (ctype_alpha($_POST['chA'])) {
$cha = $_POST['chA'];

//if (ctype_alpha($_POST['chB'])) {
$chb = $_POST['chB'];

//if (ctype_alpha($_POST['chC'])) {
$chc = $_POST['chC'];

//if (ctype_alpha($_POST['chD'])) {
$chd = $_POST['chD'];

//if (ctype_alpha($_POST['Ans'])) {
$resp = $_POST['Ans'];

//if (ctype_alpha($_POST['soln'])) {
$soln = $_POST['soln'];

//if (ctype_alpha($_POST['btch'])) {
$btch = $_POST['btch'];

//if (ctype_alpha($_POST['tps'])) {
$tps = $_POST['tps'];

//if (ctype_alpha($_POST['qsttus'])) {
$qsttus = $_POST['qsttus'];


$stMark = intval($_POST['stMark']);


//if (ctype_alpha($_POST['paragT'])) {
$paragT = $_POST['paragT'];

//----
try {
    $conn = new PDO("mysql:host=localhost;dbname=vsadb;charset=utf8", $username, $password);
	$conn->setAttribute(PDO::ATTR_EMULATE_PREPARES, FALSE);
    // set the PDO error mode to exception
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $sql="UPDATE vsaqtns SET qnatr ='$qnatr', exmtyp ='$exmtyp', dt ='$dt', sbj='$sbj', yr='$yr', questn='$questn', cha='$cha', chb='$chb', chc='$chc', chd='$chd', resp='$resp', soln='$soln', paragT='$paragT', btch='$btch', tps='$tps', qsttus='$qsttus', stMark='$stMark' WHERE pos=". $conn->quote($pos);
    //$sql="UPDATE vsaqtns SET qnatr ='$qnatr', exmtyp ='$exmtyp', dt ='$dt', sbj='$sbj', yr='$yr', questn='$questn', paragT='$paragT', cha='$cha', chb='$chb', chc='$chc', chd='$chd', resp='$resp', soln='$soln', btch='$btch', tps='$tps', qsttus='$qsttus', stMark='$stMark' WHERE pos=". $conn->quote($pos);
    //$sql = "Select * FROM vsaqtns WHERE pos="(int)$pos;
	//$sql = "Select * from vsaqtns WHERE pos=". $conn->quote($pos);
	//$sql = "UPDATE vsaqtns SET questn=? WHERE pos=?";

    // Prepare statement
    $stmt = $conn->prepare($sql);
    //$stmt = $conn->exec($sql);
    // execute the query
    $stmt->execute();

    // echo a message to say the UPDATE succeeded
    echo $stmt->rowCount() . " record(s) UPDATED successfully";

	
//	" records UPDATED successfully";
     $conn = null;
    }
catch(PDOException $e)
    {
    echo $sql . "<br>" . $e->getMessage();
    }


?>
