Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/90.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 新的mysqli_connect cat find数据库_Php_Html_Mysql_Css - Fatal编程技术网

Php 新的mysqli_connect cat find数据库

Php 新的mysqli_connect cat find数据库,php,html,mysql,css,Php,Html,Mysql,Css,这是连接到数据库的php代码。无论什么时候我试着去连接,尽管它什么都不做。我设置登录表单的方式是,操作将指向此代码,然后不执行任何操作。当我返回到索引时,它会显示“数据库未选中”,因为如果您登录,它会显示“欢迎,{username}”您可以拆分该过程 <?php $host = "localhost"; $username = "root"; $password = ""; $db = "mineforums"; $connect = mysqli

这是连接到数据库的php代码。无论什么时候我试着去连接,尽管它什么都不做。我设置登录表单的方式是,操作将指向此代码,然后不执行任何操作。当我返回到索引时,它会显示“数据库未选中”,因为如果您登录,它会显示“欢迎,{username}”

您可以拆分该过程

<?php
    $host = "localhost";
    $username = "root";
    $password = "";
    $db = "mineforums";

    $connect = mysqli_connect($host, $username, $password, $db) or die(mysqli_error($connect));
?>

OP正在使用
mysqli
,为什么
mysql
?我同意你的看法。我只是提供了一个选择。我同意,试试也无妨,干杯。让我们看看OP有什么要说的。然而,你坚持认为自己是对的,因为OP可能会混合API;OP正在混合API。你的答案会与它完全一致。我很感激+1 thanx“因为如果你登录它会说‘欢迎,{username}’”-显示包含在其中的代码。我觉得你的“张贴”代码很好。我猜你可能是把
mysqli\uquot>和
mysql\uquot>函数混在一起了;它们不会混在一起。显示完整的代码,因为从您的另一个问题的外观来看,我认为您可能正在这样做。
<?PHP
    $host = "localhost";
    $username = "root";
    $password = "";
    $db = "mineforums";

    $connect = mysql_connect($host, $username, $password)OR DIE("Could Not Connect To Server". MySQL_Error());

    if($connect) {
        mysql_select_db($db)OR DIE("Could Not Select Databse". MySQL_Error();
    }
?>