Introduction: This is Linux programming: A detailed page of five common PHP database problems. It introduces PHP, related knowledge, skills, experience, and some PHP source code.
Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 323138 'rolling = 'no'>
Expose PHP applicationsProgramFive common database problems, including database pattern design, database access, and Database Service LogicCode-- And their solutions.
If there is only one way to use the database, it is correct ......
You can create database design, database access, and database-based PHP business logic code in many ways, but it generally ends with an error. This article describes the five common problems in the PHP code for database design and database access, and how to fix these problems.
Question 1: use MySQL directly
A common problem is that older PHP Code directly uses the MySQL _ function to access the database. Listing 1 shows how to directly access the database.
|
Reference content is as follows:
<? PHP
Function get_user_id ($ name)
{
$ Db = mysql_connect ('localhost', 'root', 'Password ');
Mysql_select_db ('users ');
$ Res = mysql_query ("select ID from users where login = '". $ name ."'");
While ($ ROW = mysql_fetch_array ($ res) {$ id = $ row [0];}
Return $ ID;
}
Var_dump (get_user_id ('jack '));
?> |
Listing 1. Access/get. php
"Linux programming: five common PHP database problems"
Love J2EE follow Java Michael Jackson video station JSON online tools
Http://biancheng.dnbcw.info/php/323138.html pageno: 16.