Php MySQL没有';好像不行

Php MySQL没有';好像不行,php,Php,所以我在网上建立了我的第一个数据库。我使用了phpmyadmin,创建了表和用户。 现在,我想在我的网站页面上显示该表,并允许人们从该网站编辑数据库。 我的问题是数据库无法工作:它无法连接。我不知道该怎么办。 我的数据库名为letstenf_santi,我的表名为passegeri。 这是我试图用来在站点上显示表的代码 <?php //establishing connection mysql_connect('localhost', 'root', ''); //selecting a

所以我在网上建立了我的第一个数据库。我使用了phpmyadmin,创建了表和用户。
现在,我想在我的网站页面上显示该表,并允许人们从该网站编辑数据库。
我的问题是数据库无法工作:它无法连接。我不知道该怎么办。
我的数据库名为letstenf_santi,我的表名为passegeri。 这是我试图用来在站点上显示表的代码

<?php 
//establishing connection
mysql_connect('localhost', 'root', '');
//selecting a database
mysql_select_db('letstenf_santi');
$sql  = 'SELECT * FROM `letstenf_santi`.`passeggeri`';
$records=mysql_query($sql);
?>

<html>
 <head>
  <title>mostra</title>
 </head>
 <body>
<table width="300" border="1" cellpadding="10" cellspacing="1">
 <tr>
<th>id pass</th>
<th>nome</th>
<th>eta</th>
<th>sesso</th>
 </tr>
 <?php
 while($pass=mysql_fetch_assoc($records)){
  echo "<tr>";
echo "<td>".$pass['idpasseggero']."</td>";
echo "<td>".$pass['nome']."</td>";
echo "<td>".$pass['eta']."</td>";
echo "<td>".$pass['sesso']."</td>";
echo "</tr>";
 }
 ?>
</table>
 </body>
</html>

莫斯特拉
身份证
诺姆
希腊字母表的第7个字母
塞索
而不是这个, mysql_connect('localhost','root',''); mysql_select_db('letstenf_santi')

你可以试试这个

$connection=mysql\u connect('localhost','root','')

$db=mysql\u select\u db('letstenf\u santi',$connection)

试试这段代码

<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "letstenf_santi";//your db name

// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
}

$sql = "SELECT * FROM tablename";//replace table name with your table name
$result = mysqli_query($conn, $sql); ?>
<html>
 <head>
  <title>mostra</title>
 </head>
 <body>
<table width="300" border="1" cellpadding="10" cellspacing="1">
 <tr>
<th>id pass</th>
<th>nome</th>
<th>eta</th>
<th>sesso</th>
 </tr>
<?php if (mysqli_num_rows($result) > 0) {
    // output data of each row
    while($row = mysqli_fetch_assoc($result)) {
        echo "<tr>";
echo "<td>".$row['idpasseggero']."</td>";
echo "<td>".$row['nome']."</td>";
echo "<td>".$row['eta']."</td>";
echo "<td>".$row['sesso']."</td>";
echo "</tr>";
    }
} else {
    echo "0 results";
}

mysqli_close($conn);
?>
</table>
</body>
</html>

莫斯特拉
身份证
诺姆
希腊字母表的第7个字母
塞索

不推荐的语法检测到您遇到了什么错误?
mysql\u connect('localhost','root','')或die(mysql\u error())测试问题!不要使用
mysql\u
函数。它们已经从PHP中完全删除(从版本7开始)。请学习新的方法,如PDO。特别是,您可以将PDO设置为在异常模式下运行,这将非常清楚当事情没有按预期工作时(而
mysql\u
函数往往对此保持沉默),PDO不会像“空白页面”或“页面在那里,但数据库中的信息没有显示”?请更改此“mysql\u fetch\u assoc”进入这个“mysql\u fetch\u数组”