mysqli的问题。 [英] Problem with mysqli.

查看:42
本文介绍了mysqli的问题。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从我的桌子上显示一些记录,但是mysqli部分似乎有问题,这些是不断出现的错误;



警告:mysqli_select_db()要求参数1为mysqli,在 D:\ xampp \\\\\\\\\\\\\\\\\\\\ > 78



警告:mysqli_query()期望参数1为mysqli,字符串在 D:\\中给出\\

警告:mysqli_fetch_array()要求参数1为mysqli_result,在 D> \ xampp \ htdocs \ Project:\\ add_employees.php 90
中给出null />
ID姓名电话号码工作日期失业日期



有人可以解释错误的含义,以及我的意思做错了吗?



I want to display a few records from my table, but there seems to be a problem with the mysqli part, these are the erros that keeps popping up;

Warning: mysqli_select_db() expects parameter 1 to be mysqli, string given in D:\xampp\htdocs\Project\add_employees.php on line 78

Warning: mysqli_query() expects parameter 1 to be mysqli, string given in D:\xampp\htdocs\Project\add_employees.php on line 79

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in D:\xampp\htdocs\Project\add_employees.php on line 90
ID Name Phone Number Date Employed Date Unemployed

Can someone explain what the errors mean, and what I'm doing wrong ?

<?PHP
          $conn = new mysqli("localhost","root","");
          mysqli_select_db("kz_komputer",$conn);
          $data = mysqli_query("SELECT * FROM employees",$conn);
          
          echo "<table>
          <tr>
            <th> ID</th>
            <th> Name</th>
            <th> Phone Number</th>
            <th> Date Employed</th>
            <th> Date Unemployed</th>
          </tr>";
          
          while($record = mysqli_fetch_array($data)){
            echo "<tr>";
            echo "<td>" . $record['id'] . "</td>";
            echo "<td>" . $recod['name'] . "</td>";
            echo "<td>" . $record['phone_number'] . "</td>";
            echo "<td>" . $record['date_employed'] . "</td>";
            echo "<td>" . $record['date_unemployed'] . "</td>";
            echo "</tr>";
          }
          echo "</table>";
          
          mysqli_close($conn);
?>





我尝试过:





What I have tried:

$conn = new mysql("localhost","root","","kz_komputer");
$sql = "SELECT * FROM employees";
$data = mysql_query($sql,$conn);

推荐答案

conn = new mysqli(localhost,根,);
mysqli_select_db(kz_komputer,
conn = new mysqli("localhost","root",""); mysqli_select_db("kz_komputer",


conn);


data = mysqli_query(SELECT * FROM employees,
data = mysqli_query("SELECT * FROM employees",


这篇关于mysqli的问题。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆