我有下面的代碼:MySQL的不插入
<html><body>
<?php
$con = mysql_connect("localhost","will","blahblah");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("blahblah", $con);
$sql="INSERT INTO links (link, notes, username)
VALUES
('$_POST[link]','$_POST[notes]','$_POST[username]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "1 link added";
mysql_close($con)
?>
</body></html>
應該插入一個鏈接,註釋和用戶名到我的數據庫,但事實並非如此。我對於爲什麼會感到無能爲力,並希望得到一些幫助!它從下面的表格中獲取這些值:
<div id="stylized" class="myform">
<form id="form" name="form" method="post" action="user.php">
<label>Username
<span class="small">Enter Your Username</span>
</label>
<input type="text" name="name" id="username" />
<label>Link
<span class="small">Paste Your Link</span>
</label>
<input type="text" name="email" id="link" />
<label>Notes
<span class="small">Add Some Notes</span>
</label>
<input type="text" name="password" id="notes" />
<button type="submit"></button>
<div class="spacer"></div>
</form>
</div>
謝謝!
你有什麼錯誤? (順便說一句,用戶名輸入是「名稱」,而不是「用戶名」) – yoavmatchulsky 2011-03-12 15:19:15
錯誤說什麼? – kjy112 2011-03-12 15:19:37
沒有錯誤,只是不插入它... – 2011-03-12 15:20:55