我不知道出了什么问题,进入我的建议页面时目前没有错误,所以我不知道出了什么问题,有什么想法吗?
//index.php
<form name="suggestion" action="http://example.com/suggestions.php" method="POST">
<font style="font-family: arial; color:#3f3f3f; font-size:15px;">Provide me with a URL to one or multiple songs that you want on the website!</font> <br><br><input style="width:243px;" type="text" name="suggestion"><br>
<br>
<input value="Submit" type="submit">
</form>
//suggestions.php
<?php
$conn=mysql_connect("localhost", "u611142741_list", "[REDACTED]");
mysql_select_db("u611142741_sugge", $conn);
// If the form has been submitted
$suggestion = mysql_real_escape_string($_POST['suggestion']);
$ip = $_SERVER['REMOTE_ADDR'];
// Build an sql statment to add the student details
$sql="INSERT INTO suggestions
(Suggestion,IP Address) VALUES
('$suggestion','$ip')";
$result = mysql_query($sql,$conn);
// close connection
mysql_close($conn);
?>
答案 0 :(得分:0)
您的字段名称中有一个空格,需要引用它。你现在拥有的是什么;
INSERT INTO suggestions (Suggestion,IP Address) VALUES ('$suggestion','$ip')
...但字段名IP Address
包含一个空格,需要引用,通常在MySQL中使用反引号,导致;
INSERT INTO suggestions (Suggestion, `IP Address`) VALUES ('$suggestion','$ip')
答案 1 :(得分:0)
你可以试试这个:
$sql="INSERT INTO suggestions
(`Suggestion`,`IP Address`) VALUES
('$suggestion','$ip')";
如果有效,请告诉我。