php - 如何解决 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));
}
?>
解决方案
推荐阅读
- azure - Terraform azurerm_key_vault access_policy 覆盖现有访问策略
- python - RLLIB PPO 算法中的神经网络输出
- javascript - 我是 call api 的新手,有人可以帮我解决这个问题。使用 javascript 调用 Api 链接缩短器
- node.js - 用于特定模式的 Apollo graphql typedef
- git - 推送到远程存储库上的 temp_branch 时如何解决 git push 错误?
- maven - 通过运行 Maven 任务使用 Freemarker 生成 txt 文件
- reactjs - 是否可以使用 css 模块使用具有不同 CSS 的相同 React 组件?
- python - 创建列表的嵌套循环始终在字符串中间创建新行
- javascript - 如何在 Javascript 中循环遍历嵌套对象并随后将值添加到 HTML 表格单元格?
- typescript - 使用 yarn/npm 链接时导出类型和枚举失败