谁能看到无法连接/写入mysql数据库的原因?我不能确定是哪个,但我知道提交表单时数据没有输入。它只是路由到一个空白屏幕。
html
<html>
<div style="width: 330px; height: 130px; overflow: auto;">
<form STYLE="color: #f4d468;" action="send_post.php" method="post">
Category: <select STYLE="color: #919191; font-family: Veranda;
font-weight: bold; font-size: 10px; background-color: #000000;"
name="category">
<option value="blah1">blah1</option>
<option value="blah2">blah2</option>
<option value="blah3">blah3</option>
<option value="blah4">blah4</option>
</select> <br>
<textarea overflow: scroll; rows="4" cols="60" STYLE="color:
#919191; font-family: Veranda; font-weight: bold; font-size: 10px;
background-color: #000000; width:300px; height:80px; margin:0;
padding:0;" name="contents">
</textarea><br>
<input type="submit" STYLE="color: #919191; font-family: Veranda;
font-weight: bold; font-size: 10px; background-color: #000000;"
value="Create Log">
</form>
</div>
</html>
和 send_post.php
<?php
//Connecting to sql db.
$connect=mysqli_connect("localhost","username","password","mysqldatabasename");
//Sending form data to sql db.
mysqli_query($connect,"INSERT INTO mytablename (category, contents)
VALUES ('$_POST[category]', '$_POST[contents]')";
?>
我是新手,但我努力研究,现在陷入僵局。我试过输入检查连接错误的代码,但我总是得到一个白屏并且没有数据库更新。我将非常感谢帮助。(引号也包含在“localhost”、“username”等中吗?)