我正在创建一个表单,该表单允许用户创建票证并将其保存到MS SQL表中,他们还可以通过页面搜索票证,该页面具有一个显示该表中所有记录的表。每个记录旁边是一个“编辑”按钮,该按钮将允许用户更新记录。当用户单击“编辑”并填写字段时,出现以下错误。
PHP警告:odbc_exec():SQL错误:[Microsoft] [ODBC SQL Server 驱动程序] [SQL Server]找不到存储过程“ Test”。,SQL状态 37000在SQLExecDirect中 D:\ inetpub \ wwwroot \ SMT_Request_Dev \ board \ Dashboard \ insert.php在线 7“用于第7、8和9行
jobUpdateNew.php
$(document).ready(function(){
$('#add').click(function(){
$('#insert').val("Insert");
$('#insert_form')[0].reset();
});
$(document).on('click', '.edit_data', function(){
var jobNumber = $(this).attr("id");
$.ajax({
url:"fetch.php",
method:"POST",
data:{jobNumber:jobNumber},
dataType:"json",
success:function(data){
$('#Update_Description').val(data.Update_Description);
$('#Updated_By').val(data.Updated_By);
$('#Updated_Date').val(data.Updated_Date);
$('#jobNumber').val(data.jobNumber);
$('#insert').val("Update");
$('#add_data_Modal').modal('show');
}
});
});
$('#insert_form').on("submit", function(event){
event.preventDefault();
if($('#Update_Description').val() == "")
{
alert("Update of issue is required");
}
else if($('#Updated_By').val() == '')
{
alert("Name is required");
}
else if($('#Updated_Date').val() == '')
{
alert("Current date is required");
}
$.ajax({
url:"insert.php",
method:"POST",
data:$('#insert_form').serialize(),
beforeSend:function(){
$('#insert').val("Inserting");
},
success:function(data){
$('#insert_form')[0].reset();
$('#add_data_Modal').modal('hide');
$('#employee_table').html(data);
}
});
}
});
$(document).on('click', '.view_data', function(){
var employee_id = $(this).attr("jobNumber");
if(employee_id != '')
{
$.ajax({
url:"select.php",
method:"POST",
data:{employee_id:employee_id},
success:function(data){
$('#employee_detail').html(data);
$('#dataModal').modal('show');
}
});
}
});
});
insert.php
<?php
$connect = odbc_connect("Description=PCD_SQL_SERVER;DRIVER=SQL
Server;SERVER=gbsuk0pcdspdsql","smtrfaUser","Summitdesk789");
if(!empty($_POST))
{
$output = '';
$message = '';
$Update_Description = odbc_exec($connect,
$_POST["Update_Description"]);
$Updated_By = odbc_exec($connect, $_POST["Updated_By"]);
$Updated_Date = odbc_exec($connect, $_POST["Updated_Date"]);
if($_POST["problemDescription"] != '')
{
$query = "
UPDATE smtJobTracker
SET Update_Description='$Update_Description',
Updated_By='$Updated_By',
Updated_Date='$Updated_Date',
WHERE jobNumber='".$_POST["jobNumber"]."'";
$message = 'Data Updated';
}
else
{
$query = "
INSERT INTO smtJobTracker(Update_Description, Updated_By,
Updated_Date)
VALUES('$Update_Description', '$Updated_By', '$Updated_Date');
";
$message = 'Data Inserted';
}
if(odbc_exec($connect, $query))
{
$output .= '<label class="text-success">' . $message . '</label>';
$select_query = "SELECT * FROM smtjobTracker ORDER BY jobNumber
DESC";
$result = odbc_exec($connect, $select_query);
$output .= '
<table class="table table-bordered">
<tr>
<th>Job Number</th>
<th>Description Of Issue</th>
<th>Edit</th>
<th>View</th>
</tr>
';
while($row = odbc_fetch_array($result))
{
$output .= '
<tr>
<td>' . $row["jobNumber"] . '</td>
<td><input type="button" name="edit" value="Edit"
id="'.$row["jobNumber"] .'" class="btn btn-info btn-xs edit_data" />
</td>
<td><input type="button" name="view" value="view"
id="' . $row["jobNumber"] . '" class="btn btn-info btn-xs view_data" />
</td>
</tr>
';
}
$output .= '</table>';
}
echo $output;
}
?>
目标是对记录进行更新,以包括更新描述,更新者的名称和更新日期。