Analysis on the differences between mysql and mysqli in php _ MySQL

Source: Internet
Author: User
Analysis on the differences between mysql and mysqli in php bitsCN.com 1:
PHP-MySQL is the most primitive Extension for PHP to operate MySQL databases. I of PHP-MySQLi stands for Improvement and provides more advanced functions. Extension also increases security. The PDO (PHP Data Object) provides an action Layer to operate the database. The difference is not obvious, so let's look at the program directly...
First, let's look at a piece of code written in PHP-MySQL. such examples are often used around the world:

Mysql_connect ($ db_host, $ db_user, $ db_password );
Mysql_select_db ($ dn_name );
$ Result = mysql_query ("SELECT 'name' FROM 'users' WHERE 'location' = '$ location '");
While ($ row = mysql_fetch_array ($ result, MYSQL_ASSOC ))
{
Echo $ row ['name'];
}
Mysql_free_result ($ result );
?>

At first glance, there is no problem, but there is actually some knowledge behind it...
This method cannot Bind Column. in the previous SQL statement, $ location is prone to SQL Injection. Later, I developed mysql_escape_string () (remarks: abandon after 5.3.0) and mysql_real_escape_string () to solve this problem.

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.