One: Mysqli.dll is a database that allows the operation of objects in a way or process, and it is easy to use. Here is a comparison of a few common operations and mysql.dll.
1:mysql.dll (can be understood as a functional approach):
$conn = mysql_connect (' localhost ', ' user ', ' password ');//Connect MySQL database
mysql_select_db (' data_base ');//Select Database
$result = mysql_query (' select * from Data_base ');//There is a second optional parameter that specifies the open connection
$row = mysql_fetch_row ($result))//For simplicity, only one row of data is taken here
echo $row [0];//output The value of the first field
Mysqli also have a procedural approach, but start with the mysqli prefix, the others are similar. If Mysqli is manipulated in a procedural way, some functions must specify a resource, such as mysqli_query (resource ID, SQL statement), and the resource identification parameter is placed in front, while the mysql_query (SQL statement, ' optional ') resource identifier is placed in the back , and can not be specified, it is the last open connection or resource by default.
2mysqli.dll (object mode):
$conn = new mysqli (' localhost ', ' user ', ' password ', ' data_base ');
//The connection here is new, the last parameter is to specify the database directly, without mysql_select_db ()
//can also be constructed when not specified, then $conn-select_db (' data_base ')
$result = Query (' SELECT * from Data_base '), $conn
$row = $result-Fetch_row (); Fetch a row of data
Echo row[0];//output The value of the first field
II: mysql_fetch_row (), Mysql_fetch_array ( )
These two functions return an array, the difference is that the first function returns an array that contains only the values, we can only $row[0],
$row [1], which reads the data as an array subscript, and the array returned by Mysql_fetch_array () contains both the first and key values
In the right form, we can read the data in this way (if the database field is USERNAME,PASSWD):
$row [' username '], $row [' passwd ']
Furthermore, if you use ($row as $kay + $value), you also get the field name of the database directly.
more important is that mysqli is a new library of functions provided by PHP5, (i) for improvement, and for faster execution.
-----------------------------------------------------------------------------
your SQL error is because you call mysqli the wrong way
Reference:
$conn = new mysqli (' localhost ', ' user ', ' password ', ' data_base ');
//The connection here is new, the last parameter is to specify the database directly, without mysql_select_db ()
//can also be constructed when not specified, then $conn-select_db (' data_base ')
$result = Query (' SELECT * from Data_base '), $conn
The difference between Mysqli_connect and mysql_connect