CopyCode The Code is as follows: <? PHP
Require_once "DB. php"; // contains the class library file
$ Conn = DB: connect ("MYSQL: // root: 1981427 @ localhost/test"); // connect to the database
If (! DB: iserror ($ conn) {// determine whether the connection is successful
Print "database connection successful ";
}
Else
{
Echo "database connection failed! ";
}
?>
copy the Code the code is as follows: require_once "DB. PHP ";
$ conn = DB: connect (" MYSQL: // root: 1981427 @ localhost/test "); // call connect to the database
If (DB: iserror ($ conn )) // If a connection error occurs, an error is returned.
{< br> Print "database connection failed ";
}< br> $ rs = $ Conn-> query ("select ID, username, password from tablename1"); // execute an SQL statement
If (DB:: iserror ($ RS) // determines whether execution is successful
{< br> Print "Data Query failed ";
}< br> while ($ RS-> fetchinto ($ rows) // output the query result cyclically
{< br> Print "no.: $ Rows [0]
";
Print" Name: $ rows [1]
";
Print" password: $ rows [2]
";
Print"
";
}< BR >?>
copy the Code the code is as follows: require_once "DB. PHP ";
$ conn = DB: connect (" MYSQL: // root: 1981427 @ localhost/test "); // call connect to the database
If (DB: iserror ($ conn )) // If a connection error occurs,
{< br> Print "database connection failed";
}< br> // run the SQL statement, returns one record starting with 0th records
$ rs = $ Conn-> limitquery ("select ID, username, password from tablename1 ); // query the third to sixth data records in the record set
If (DB: iserror ($ RS )) // if an error occurs during query, an error is returned.
{< br> Print "Data Query failed";
}< br> while ($ RS-> FET Chinto ($ rows) // cyclically output query results
{< br> Print "No.: $ rows [0]
";
Print "Name: $ rows [1]
";
Print" Password: $ rows [2]
";
Print"
";
}< BR >?>
copy the Code the code is as follows: require_once "DB. PHP ";
$ conn = DB: connect (" MYSQL: // root: 1981427 @ localhost/test "); // connect to the database
If (DB:: iserror ($ conn)
{< br> Print "database connection failed ";
}< br> // use the prepare function to prepare an SQL statement
$ rs = $ Conn-> prepare ("Update tablename1 SET Password = 'Susan 'where id =' 1 '");
If (DB: iserror ($ RS)
{< br> Print "data update failed ";
}< br> else
{< br> $ Conn-> execute ($ RS); // Execute SQL statements to update the database
Print "data more New success ";
}< BR >?>