首页 > 解决方案 > 如何解决 phpmyadmin “未知数据库”中的此数据库错误

问题描述

我正在一个食品餐厅网站上工作,每当我尝试将数据提交到数据库时,它都会显示:未知数据库美食家。“foodies”是我的数据库的名称。我还进入了phpmyadmin以确认我的数据库“foodies”存在,我还确认每个列都正确创建。但我不知道为什么它一直显示Unknown database foodies。请我需要帮助。下面是代码:

<?php 


      if(isset($_POST['submit']))
      {
         // if button is clicked
         //1. This code will get the data from the form. 

       $full_name = $_POST['full_name'];
       $username = $_POST['username'] ;
       $password = md5($_POST['password'] ); //password encrypted with md5


        // 2.the sql query will send the collected from the form to the database

       $sql = " INSERT INTO admin_1 SET
            full_name ='$full_name',
            username = '$username',
            password ='$password'

       ";

       // 3.This will execute the query and save it into the database

        $conn = mysqli_connect('localhost','root','<password>') or die(mysqli_error($conn)); 

        $db_select = mysqli_select_db($conn,'foodies') or die(mysqli_error($conn)); 

        $res = mysqli_query($conn, $sql) or die(mysqli_error($conn));        

       }

 ?> 

标签: phphtmlcssmysql

解决方案


推荐阅读