使用php插入sql server数据库时出错


Error with insert into sql server database with php

我有错误插入多列数据到SQL Server数据库与PHP

php代码:

<?php
    $serverName = "GHAREBAGHI'sqlexpress, 1433";
    $connectionInfo = array( "Database"=>"PwKara", "UID"=>"test","PWD"=>"100100");
    $conn = sqlsrv_connect( $serverName, $connectionInfo);
    if( $conn ) {
        echo "Connection established.<br />";
    } else {
        echo "Connection could not be established.<br />";
        die( print_r( sqlsrv_errors(), true));
    }
    $tsql= "INSERT INTO Requests
  (EMP_NO ,SubmittedDate ,Type ,StartDate ,EndDate ,StartHour ,EndHour
,Duration ,SubmittedByEmployeeID ,OperationsID ,Description ,CurEmp_NO ,AcceptCode ,IsWardenCheck ,RequestStatus ,IOStatus ,CurSection)
VALUES
(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
    $para = array("93229 ,'2016-10-19 09:23:48.850' ,54 ,'2016-10-19 09:23:48.850' ,'2016-10-19 09:23:48.850' ,2359 ,2359 ,2 ,83229 ,3 ,'php test' ,8813 ,0 ,0 ,0 ,0 ,6");
    if (!sqlsrv_query($conn, $tsql, $para)){
        die('Error: ' . sqlsrv_errors());
    }
    echo "1 record added"; 
?>

结果:php错误码(数组到字符串的转换在第52行)

指出错误的那一行:

die('Error: ' . sqlsrv_errors());

$para = array为什么在" .... " ?这不是数组,这是字符串。删除两边的"""。它就像:

$para = array(93229, '2016-10-19 09:23:48.850', 54, '2016-10-19 09:23:48.850', '2016-10-19 09:23:48.850', 2359, 2359, 2, 83229, 3, 'php test', 8813, 0, 0, 0, 0, 6);