<html>
<head><title>HEllo</title></head>
<body>
<input type="text" name="id">
<input type="text" name="name">
<input type="text" name="address">
<input type ="submit" name = "s" value = "Employee">
<?php
$link =mysql_connect('localhost','root') or die("Failed");
mysql_select_db("gagan",$link) or die("database not exists");
if($_POST['s']=="Employee")
{
print "g";
$id = mysql_real_escape_string($_POST['id']);
$name = $_POST['name'];
$address = $_POST['address'];
print "hi";
$update = "update emp set name = $name, address=$address where id = $id";
$result = mysql_query($update,$link);
print "Hello";
if($result)
{
print "Updated";
}
else{
print "$update";
}
}
?>
</body>
</html>
當我運行此代碼時,它會生成通知,並且上述代碼無法工作。
公告:未定義的索引:■在C:\ WAMP \ WWW \ 1.PHP上線12
是什麼在我的代碼問題有誰能夠告訴我嗎?
你發佈's'變量嗎? –
嘗試刪除中不必要的空格> –
注意:如何在三個值之一中使用'mysql_real_escape_string()'? –