Delete database data on the webpage. This post was last edited by misteryangbin from 2015-01-0416: 51: 28 & lt ;? Php & nbsp; $ id & nbsp; $ _ POST [id]; get ID $ id & nbsp; & nbsp; isset ($ delete database data on the webpage
This post was last edited by misteryangbin at 16:51:28 on
// $ Id = $ _ POST ['id']; // obtain the id to be deleted
$ Id = isset ($ _ GET ['id'])? $ _ GET ['id']: '';
// Write your linked database code here
Echo $ id;
$ ServerName = "192.168.1.100, 35890 ";
$ Database = "ee ";
$ Uid = "sa ";
$ Pwd = "123 ";
Try {
$ Conn = new PDO ("sqlsrv: server = $ serverName; Database = $ database", $ uid, $ pwd );
}
Catch (PDOException $ e ){
Die ("Error connecting to SQL Server". $ e );
}
$ Conn-> exec ("delete from employee portfolio where _ Identify = '$ ID '");
?>
As shown in the code, the id value is obtained from another php file, and the test value is successful.
But $ conn-> exec ("delete from employee Archive table where _ Identify = '$ ID'"); no execution is performed. why?
Is it because the $ conn-> exec method is incorrect? Please kindly advise. Thank you!
------ Solution ----------------------
$ Conn-> exec ("delete from employee portfolio where _ Identify = '$ ID '");
Remove the single quotes of $ id
------ Solution ----------------------
Chinese table name?
"Delete from [employee Archive table] where _ Identify = '$ ID '"
Note the character set!
Print_r ($ conn-> errorInfo ());
View Results
------ Solution ----------------------
If it is Chinese, encoding may be used.
Chinese characters are not recommended for table names and field names.