<?php
$sql = "SELECT MAX(REQUEST_ID) AS REQUEST_ID FROM TBL_REQUEST;";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt === false) {
echo "alert('DataBase Error');";
}
else{
$row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC);
$newReqId=$row['REQUEST_ID']+1;
}
$sql = "INSERT INTO TBL_REQUEST VALUES(".$newReqId.",\'ISSUE\',\'Test\',\'Test\',\'NSNS05\',1);";
$newsql = $sql;
$stmt = sqlsrv_query( $conn, $newsql );
if( $stmt === false) {
echo "alert('Not Inserted '+assoc_id+' ".$stmt." '+' ".$newsql." ');";
}
else{
echo "alert('Inserted '+assoc_id+' ".$stmt."');";
}
?>
在上面的代码中,我使用了2个SQL语句,第一个是一个select语句,可以正常工作并从表中获取数据,但是当我在同一个表上执行Insert时,它不起作用...
INSERT INTO TBL_REQUEST VALUES(4016,'ISSUE','Test','Test','NSNS05',1);
那是
的字符串答案 0 :(得分:0)
为什么在""
之间使用""
' '
$newReqId
$sql = "INSERT INTO TBL_REQUEST VALUES(".$newReqId.",\'ISSUE\',\'Test\',\'Test\',\'NSNS05\',1);";