? <php
echo "Hello Word <br>"; // test could not be resolved php code
echo date ( 'Ymd H: i : s'); // time of test development environment does not
echo '<br>';
/ address database service account password database name / four parameters of the database
$ db = new new MySQLi ( 'localhost', 'root', 'root', 'z_0222');
! mysqli_connect_error () or Die ( 'database connection failed'); // If the database connection error given
$ db-> query ( 'set names utf8'); // set the format database UTF8
// var_dump ($ DB); // can not be connected to the test database, the database is a printing
$ sql = 'select * from student'; // sql statement
$ result = $ db-> query ( $ sql); // sql statement execution, additions and deletions to which it
// if ($ result) {// If successful statement CRUD
// echo 'successfully executed';// output successfully executed
//}
// If query, returns the resources, the resources need to be converted into identification data php
$ ARR = $ result-> fetch_all ();
echo '<pre>'; // to pre format
var_dump ($ arr); // there is no test data, the print data
echo '</ pre>';
?>
Test whether the database connection success
Guess you like
Origin www.cnblogs.com/PHP0222wangdong/p/10965588.html
Recommended
Ranking