search

Home  >  Q&A  >  body text

PHP database connection problem

Experts, please help me see if I write this correctly

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

<?php

$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 '<pre>';

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()

杜紫藤杜紫藤2059 days ago1339

reply all(2)I'll reply

  • 王林

    王林2019-08-15 16:26:49

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

    reply
    0
  • Alone88

    Alone882019-05-18 14:21:09

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

    reply
    0
  • Cancelreply