PHP database connection problem
杜紫藤
杜紫藤 2019-05-16 10:19:48
0
2
1207

Experts, please help me see if I write this correctly

-------------------------------- --------

$adminunix = "localhost";

$adminname = "root";

$adminpass = "root";

$admindb = "ckq";

//Connect to the database

$conn =new mysqli($adminunix,$adminname ,$adminpass,$admindb);

//Check the connection

if($conn->connect_error){

die("Connection failed". $conn->connect_error);

}

$sql = "SELECT * FROM lrx ";

$result = $conn-> ;query($sql);

if ($result->num_rows > 0) {

echo $result->num_rows;

while ($row=mysqli_fetch_assoc($result)){

echo '

';

var_dump($row);

}

}

$conn->close();

?>

------------- -----------------------

Question 1: How many methods are there in the mysqli class?

Question 2: $ Can row=mysqli_fetch_assoc($result) be written like this?

Question 3: ->What is the difference between num_rows and mysqli_num_rows()

杜紫藤
杜紫藤

reply all (2)
V

There are many ways to connect to the database, such as object-oriented or process-oriented, and PDO.

    Alone88

    These problems can all be solved in practice, and the truth can be obtained through practice

      Latest Downloads
      More>
      Web Effects
      Website Source Code
      Website Materials
      Front End Template
      About us Disclaimer Sitemap
      php.cn:Public welfare online PHP training,Help PHP learners grow quickly!