Php cannot delete records in mssql. php cannot delete records in mssql.
The table structure in mssql is as follows:
Because hr_id is a string in the uniqueidentifier format generated by mssql, I cannot use php to read this string. it is a word value queried by mssql. now, for example, if I want to delete the first value, you cannot delete this record after Clicking delete:
The code for deleting a link on the previous page is as follows:
// ================================================ =
Echo"Delete | modify";
========================================================== =
The del statement is as follows:
Require_once ("c_class.php ");
Require_once ("c_init.php ");
$ Db = new msSQL ($ db_IP, $ db_user, $ db_sa, $ db_dbName, "conn ");
// Mssql_query ("set names 'utf-8 '");
// Mssql_query ('set NAMES GB2312 ');
$ SQL = "delete from". $ tablea. "where recv_time =". urldecode ($ _ GET [recv_time]);
$ Del = mysql_query ($ SQL );
If ($ del ){
Echo "script" alert ('successful '); history. back (); script ";
} Else {
Echo "script" alert ('fales'); history. back (); script ";
}
========================================
The deletion fails.
How can this problem be solved ??
In addition, how can I specify only one record for a php operation (such as modification or deletion? Mysql can use the SQL statement limit to limit the SQL statement, but it seems that mssql does not have this limit parameter to limit the SQL statement. how can I write the SQL statement to operate mssql in php ??
Reply to discussion (solution)
$sql = "delete from ".$tablea." where recv_time = '".urldecode($_GET[recv_time])."'";
The single quotation marks are missing.
The record cannot be deleted because it remains the same after correction.
The record cannot be deleted because it remains the same after correction.
Print $ SQL.
The $ SQL statement output by echo is as follows:
Delete from hr_atd_recv where recv_time = '2017-03-27 17:44:00'
You can run it correctly in the mssql query analyzer.
Somehow, php cannot run. Dizzy !!
I have done it myself. I used the wrong function on the first floor. Mysql_query should be written as mssql_query.
Careless.