我正在使用PHP 7.1.7
和XAMMP
来构建一个小应用程序。
我试图连接到我通过phpMyAdmin使用mysqli
创建的名为'shop'的mySQL数据库时遇到了1049错误。
我很困惑,因为你可以在这里看到名为'shop'的数据库已经在phpMyAdmin中设置了。任何转向都会受到赞赏。
的functions.php
<?php
//create connection
$db = new mysqli('127.0.0.1','root','','shop');
echo $db->connect_errno; // take error reporting off in production mode
的index.php
<?php
error_reporting(E_ALL); // turn this off in production mode -
require 'db/functions.php';
?>
<link rel="stylesheet" href="index.css" media="all">
<!DOCTYPE html>
<html>
<head>
<title>Dorman Shop</title>
</head>
<body>
<div class = main_wrapper>
<div class ="header_wrapper"><!-- /. this section here is for our header above-->
<img src="https://s122939.gridserver.com/clients/concept/logo.svg" class="logo"/>
</div>
<div class ="menu_bar"><!-- /. we code our nav bar here aka the UL LI-->
<ul id ="menu">
<li><a href="#">Home</a></li>
<li><a href="#">All Products</a></li>
<li><a href="#">My Account</a></li>
<li><a href="#">Sign Up</a></li>
<li><a href="#">Shopping Cart</a></li>
<li><a href="#">Contact Us</a></li>
</ul>
<div id="form ">
<form method="get" action="results.php" enctype="multipart/form-data">
<input type="text" name="user_query" placeholder="search our products" />
<input type="submit" name="search" value="Search" />
</form>
</div>
</div>
<div class = "content_wrapper"><!-- /. this is our content wrapper container-->
<div id ="sidebar">
<div id="sidebar_title">Categories</div>
<ul id="cats">
<?php getCats();?> <!-- /. this runs the getCats function in functions.php-->
</ul>
<div id="sidebar_title">Brands</div>
<ul id="cats">
<li><a href="#">HP</a></li>
<li><a href="#">DELL</a></li>
<li><a href="#">Motorola</a></li>
<li><a href="#">Sony Ericsson</a></li>
<li><a href="#">LG</a></li>
<li><a href="#">Apple</a></li>
</ul>
</div>
<div id = "content_area">
<h3>this is the content area for all of our gear</h3>
</div>
</div>
<div id = "footer"><!-- /. this is the footer -->
<h3>this is the footer</h3>
</div>
</div> <!-- /. END OF main_wrapper -->
</body>
</html>