How to delete database data on a webpage

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.