在PHP上将数据插入MSSQL时结果为“ NULL”

时间:2018-09-21 06:17:15

标签: php sql-server

您好,我正在尝试在PHP上将数据插入MSSQL。 但是结果出来是“ NULL”。任何想法?预先感谢。

数据库结果: Database Result 附加数据库图像结果。

insert.php

$serverName = "192.168.0.5";
$dbName = "GAProduction";
$connectionInfo = array( "Database"=>"GAProduction" );

$conn = sqlsrv_connect( $serverName, $connectionInfo);

if( $conn === false ) {
    die( print_r( sqlsrv_errors(), true));
}

$sql = "INSERT INTO pd_output (location, date_time, qty) VALUES (?, ?, ?)";
$params = array($_POST["txtlocation"], $_POST["txtdate_time"], $_POST["txtqty"]);

$stmt = sqlsrv_query( $conn, $sql, $params);
if( $stmt === false ) {
     die( print_r( sqlsrv_errors(), true));
}
else
{
    echo "Record add successfully";
}

sqlsrv_close($conn);

add.php

<html>
<head>
<title>Production Output</title>
</head>
<body>
<form action="insert.php" name="frmAdd" method="post">
<table width="600" border="1">
  <tr>
    <th width="91"> <div align="center">Location </div></th>
    <th width="160"> <div align="center">Date </div></th>
    <th width="198"> <div align="center">Quantity </div></th>

  </tr>
  <tr>
    <td><div align="center"><input type="text" name="txtlocation" size="5"></div></td>
    <td><input type="text" name="txtdate_time" size="20"></td>
    <td><input type="text" name="txtqty" size="20"></td>

  </tr>
  </table>
  <input type="submit" name="submit" value="submit">
</form>
</body>
</html>

0 个答案:

没有答案