我刚接触编码,无法连接到我创建的数据库,我真的无法进一步移动因为我需要访问它才能添加,显示和操作数据。请有人帮我理解我做错了什么? ?????我的php和html表单如下。我用表创建了一个数据库但是没有添加信息。
attachedCallback
<form id="details" action="Seller.php" method="post">
<div class="textdiv">
Enter the title for the advertisemennt
<input type="text" id="adtitle"></input><br/>
Sellers name
<input type="text" id="sellersname"> </input><br/>
Email id
<input type="text" id="email"></input><br/>
Enter A brief description of the necessary details for the product
<textarea rows="10" cols="30" id="description"></textarea><br/>
<br/>
Choose a category
<select name="product">
<option value="Electronics">Electronics</option>
<option value="Cars">Cars</option>
<option value="pets">pets</option>
<option value="furniture">furniture</option>
<option value="appliances">appliances</option>
<option value="books">books</option>
<option value="other">other</option>
</select>
<br/>
<br/>
Enter your mobile number
<input type="text" id="phone number"> </input> <br/> <br/>
your phone number will be kept private .<br/> <br/>
Selling price
<input type="text" id="base"></input><br>
Cutoff price ( the price below which you will not sell )
<input type="text" id="cutoff"></input><br>
</form></div>
答案 0 :(得分:0)
尝试使用此代码连接到mysql数据库。
$serverName = "localhost";
$userName = "root";
$password = "";
$database = "seller";
$db = new mysqli( $serverName, $userName, $password, $database );
if ( $db -> connect_errno ) {
echo "Failed to connect to MySQL: (" . $db -> connect_errno . ") " . $db -> connect_error;
} else {
echo "You are connected to your database. <br><br>";
}