我的两个代码都有
解析错误:语法错误,意外的文件结尾
我该如何解决?我只是一名学生,这是一个功课。对不起,如果太多的错误,仍在学习。
更新代码:
<?php include "dbConfig.php";
error_reporting(E_ALL);
$msg = "";
$db_id=$_POST['db_id'];
$sql="SELECT * FROM registry WHERE db_id='$db_id'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
<?php
while($rows=mysql_fetch_array($result)){
?>
<?php
删除代码:
<?php include "dbConfig.php";
error_reporting(E_ALL);
$msg = "";
if(isset($_POST['Submit'])){
$db_id = $_GET['db_id'];
$sql = mysql_query("DELETE from registry WHERE db_id
='$db_id',db name = '$name', db_age = '$age', db_gender = '$gender',
db_birthdate = '$bdate', db_phone = '$phone', db_address = '$address'");
if($sql > 0)
{
echo"record successfully deleted";
}
else
{
echo "error in deleting";
}
?>
<div id='cssmenu'>
<ul>
<li class='active'><a href='home.php'><span>Home</span></a>
</li>
<li><a href='save.php'><span>Save</span></a></li>
<li><a href='update.php'><span>Update</span></a></li>
<li class='last'><a href='delete.php'><span>Delete</span></a>
</li>
</ul>
</div>
<form name="frmregister"action="<?php echo $_SERVER['PHP_SELF']?>"
method="post" >
<table class="form" border="0">
<tr>
<td></td>
<td style="color:red;">
<?php echo $msg; ?></td>
</tr>
<tr>
<th><label for="name"><strong>Employee ID:</strong></label></th>
<td><input name = "db_id" type = "text" id = "db_id" size="30"
/></td>
</tr>
<td class="button">
<a href="delete.php?id=<?php echo $row['db_id'] ?>"><input type="button"
name="delete" value="Delete"></a>
</td>
</table>
</form>
</body>
</html>
答案 0 :(得分:3)
while($rows=mysql_fetch_array($result)){
没有结尾}
答案 1 :(得分:0)
您尚未结束if(isset($_POST['Submit'])){
代码块。你需要一个}
。我会让你弄清楚它会发生什么。
答案 2 :(得分:0)
<?php include "dbConfig.php";
error_reporting(E_ALL);
$msg = "";
$db_id=$_POST['db_id'];
$sql="SELECT * FROM registry WHERE db_id='$db_id'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
while($rows=mysql_fetch_array($result)){
}
?>
if(isset($_POST['Submit'])){
$db_id = $_GET['db_id'];
$sql = mysql_query("DELETE from registry WHERE db_id
='$db_id'");
if($sql > 0)
{
echo"record successfully deleted";
}
else
{
echo "error in deleting";
}
}
?>
答案 3 :(得分:0)
对于DELETE您可以使用:
if(isset($_GET['delete_id']))
{
$sql ="DELETE from registry WHERE db_id=".$_GET['delete_id'];
$result=$mysqli->query($sql);
header("Location:filename.php");
}