PHP:Can';找不到我的数据库

PHP:Can';找不到我的数据库,php,database,phpmyadmin,Php,Database,Phpmyadmin,我在连接数据库时遇到问题 <?php @mysqli_connect( "127.0.0.1", "root", "root" ) or die( "Cannot connect to the database!" ); @mysqli_select_db( "phpherexamen" ) or die( "Connected to the database, but there's nothing here!" ); session_start(); ?> 您应该使用mys

我在连接数据库时遇到问题

<?php

@mysqli_connect( "127.0.0.1", "root", "root" ) or die( "Cannot connect to the database!" );
@mysqli_select_db( "phpherexamen" ) or die( "Connected to the database, but there's nothing here!" );
session_start();

?>

您应该使用mysqli\u connect函数的结果作为mysql\u select\u db函数的第二个参数

$link = mysqli_connect( "127.0.0.1", "root", "root" )
if (!$link) {
    die("Cannot connect to the database!");
}

$db_selected = mysql_select_db('phpherexamen', $link);
if (!$db_selected) {
    die ("Connected to the database, but there's nothing here!");
}

您应该使用mysqli\u connect函数的结果作为mysql\u select\u db函数的第二个参数

$link = mysqli_connect( "127.0.0.1", "root", "root" )
if (!$link) {
    die("Cannot connect to the database!");
}

$db_selected = mysql_select_db('phpherexamen', $link);
if (!$db_selected) {
    die ("Connected to the database, but there's nothing here!");
}

您应该使用mysqli\u connect函数的结果作为mysql\u select\u db函数的第二个参数

$link = mysqli_connect( "127.0.0.1", "root", "root" )
if (!$link) {
    die("Cannot connect to the database!");
}

$db_selected = mysql_select_db('phpherexamen', $link);
if (!$db_selected) {
    die ("Connected to the database, but there's nothing here!");
}

您应该使用mysqli\u connect函数的结果作为mysql\u select\u db函数的第二个参数

$link = mysqli_connect( "127.0.0.1", "root", "root" )
if (!$link) {
    die("Cannot connect to the database!");
}

$db_selected = mysql_select_db('phpherexamen', $link);
if (!$db_selected) {
    die ("Connected to the database, but there's nothing here!");
}

使用过程风格
mysqli
时,您需要传递
mysqli\u select\u db
一个
mysqli

$mysqli = mysqli_connect("127.0.0.1", "root", "root");
mysqli_select_db($mysqli, "phpherexamen");

使用过程风格
mysqli
时,您需要传递
mysqli\u select\u db
一个
mysqli

$mysqli = mysqli_connect("127.0.0.1", "root", "root");
mysqli_select_db($mysqli, "phpherexamen");

使用过程风格
mysqli
时,您需要传递
mysqli\u select\u db
一个
mysqli

$mysqli = mysqli_connect("127.0.0.1", "root", "root");
mysqli_select_db($mysqli, "phpherexamen");

使用过程风格
mysqli
时,您需要传递
mysqli\u select\u db
一个
mysqli

$mysqli = mysqli_connect("127.0.0.1", "root", "root");
mysqli_select_db($mysqli, "phpherexamen");

将连接存储在变量中,然后将其传递给select_db命令

$db = mysqli_connect(...);
mysqli_select_db($db, 'phpherexamen');

将连接存储在变量中,然后将其传递给select_db命令

$db = mysqli_connect(...);
mysqli_select_db($db, 'phpherexamen');

将连接存储在变量中,然后将其传递给select_db命令

$db = mysqli_connect(...);
mysqli_select_db($db, 'phpherexamen');

将连接存储在变量中,然后将其传递给select_db命令

$db = mysqli_connect(...);
mysqli_select_db($db, 'phpherexamen');

是否使用面向对象的样式:

$handle = @mysqli_connect( "127.0.0.1", "root", "root" ) or die( "Cannot connect to the database!" );
$handle->mysqli_select_db( "phpherexamen" ) or die( "Connected to the database, but there's nothing here!" );
或程序风格:

$handle = @mysqli_connect( "127.0.0.1", "root", "root" ) or die( "Cannot connect to the database!" );
    @$mysqli_select_db($handle, "phpherexamen" ) or die( "Connected to the database, but there's nothing here!" );
但是Mysqli需要一个对象来知道mysql select数据库应该应用于哪个连接


旁注:被MySQLi替换的旧扩展MySQL支持缓存最后一个连接,因此您不需要指定数据库句柄,但如果您有一个使用多个连接的网站,或者希望在循环结果或类似结果时触发查询,那么这是一个巨大的错误磁铁。为什么这只适用于有效句柄或更好的句柄所说的对象比另一种旧方法更理智。

无论您使用的是面向对象的样式:

$handle = @mysqli_connect( "127.0.0.1", "root", "root" ) or die( "Cannot connect to the database!" );
$handle->mysqli_select_db( "phpherexamen" ) or die( "Connected to the database, but there's nothing here!" );
或程序风格:

$handle = @mysqli_connect( "127.0.0.1", "root", "root" ) or die( "Cannot connect to the database!" );
    @$mysqli_select_db($handle, "phpherexamen" ) or die( "Connected to the database, but there's nothing here!" );
但是Mysqli需要一个对象来知道mysql select数据库应该应用于哪个连接


旁注:被MySQLi替换的旧扩展MySQL支持缓存最后一个连接,因此您不需要指定数据库句柄,但如果您有一个使用多个连接的网站,或者希望在循环结果或类似结果时触发查询,那么这是一个巨大的错误磁铁。为什么这只适用于有效句柄或更好的句柄所说的对象比另一种旧方法更理智。

无论您使用的是面向对象的样式:

$handle = @mysqli_connect( "127.0.0.1", "root", "root" ) or die( "Cannot connect to the database!" );
$handle->mysqli_select_db( "phpherexamen" ) or die( "Connected to the database, but there's nothing here!" );
或程序风格:

$handle = @mysqli_connect( "127.0.0.1", "root", "root" ) or die( "Cannot connect to the database!" );
    @$mysqli_select_db($handle, "phpherexamen" ) or die( "Connected to the database, but there's nothing here!" );
但是Mysqli需要一个对象来知道mysql select数据库应该应用于哪个连接


旁注:被MySQLi替换的旧扩展MySQL支持缓存最后一个连接,因此您不需要指定数据库句柄,但如果您有一个使用多个连接的网站,或者希望在循环结果或类似结果时触发查询,那么这是一个巨大的错误磁铁。为什么这只适用于有效句柄或更好的句柄所说的对象比另一种旧方法更理智。

无论您使用的是面向对象的样式:

$handle = @mysqli_connect( "127.0.0.1", "root", "root" ) or die( "Cannot connect to the database!" );
$handle->mysqli_select_db( "phpherexamen" ) or die( "Connected to the database, but there's nothing here!" );
或程序风格:

$handle = @mysqli_connect( "127.0.0.1", "root", "root" ) or die( "Cannot connect to the database!" );
    @$mysqli_select_db($handle, "phpherexamen" ) or die( "Connected to the database, but there's nothing here!" );
但是Mysqli需要一个对象来知道mysql select数据库应该应用于哪个连接


旁注:被MySQLi替换的旧扩展MySQL支持缓存最后一个连接,因此您不需要指定数据库句柄,但如果您有一个使用多个连接的网站,或者希望在循环结果或类似结果时触发查询,那么这是一个巨大的错误磁铁。为什么这只适用于有效句柄或更好的句柄所说的对象比另一个旧方法更理智。

该表是有效名称吗?(比如,他们可以有空格吗?@Lee,如果你指的是“Nieuwe tabel aanmaken”。。。这在荷兰语中只是“makenewtable”的意思,实际上它不是一个表名:PYou真的应该停止抑制错误消息。否则,当您遇到空白页面(没有错误)时,您将得到一张空白的脸。改为添加一些错误处理和日志记录,并正常失败:-)该表是有效名称吗?(比如,他们可以有空格吗?@Lee,如果你指的是“Nieuwe tabel aanmaken”。。。这在荷兰语中只是“makenewtable”的意思,实际上它不是一个表名:PYou真的应该停止抑制错误消息。否则,当您遇到空白页面(没有错误)时,您将得到一张空白的脸。改为添加一些错误处理和日志记录,并正常失败:-)该表是有效名称吗?(比如,他们可以有空格吗?@Lee,如果你指的是“Nieuwe tabel aanmaken”。。。这在荷兰语中只是“makenewtable”的意思,实际上它不是一个表名:PYou真的应该停止抑制错误消息。否则,当您遇到空白页面(没有错误)时,您将得到一张空白的脸。改为添加一些错误处理和日志记录,并正常失败:-)该表是有效名称吗?(比如,他们可以有空格吗?@Lee,如果你指的是“Nieuwe tabel aanmaken”。。。这在荷兰语中只是“makenewtable”的意思,实际上它不是一个表名:PYou真的应该停止抑制错误消息。否则,当您遇到空白页面(没有错误)时,您将得到一张空白的脸。改为添加一些错误处理和日志记录,并优雅地失败:-)非常感谢您的回复!非常感谢您的回复!非常感谢您的回复!非常感谢您的回复!谢谢你的回复,谢谢!谢谢你的回复,谢谢!谢谢你的回复,谢谢!谢谢你的回复,谢谢!