解析错误:语法错误,表单不显示

时间:2014-03-05 18:24:00

标签: php

这是我的代码
它给我一个错误的最后一行
代码不显示任何形式或输入
我尝试过所有的事情 加上我是编程的新手

<?php


 if($connect=mysqli_connect('localhost','root','','sy_gov')){

 $sql="SELECT * FROM threads WHERE id='$id'";
 $query=mysqli_query($connect,$sql);
 while($row=mysqli_fetch_object($query)){

?>
<form action="<?php echo $_SERVER['$PHP_SELF'];?>" method="post">

<input type="hidden" name="id" value="<?php  echo $row->id;?>">
<input type="text" name="topic" value="<?php echo $row->topic;?>">
<input type="submit" value="refresh">
</form>


<?
}

 $sql2="UPDATE threads SET topic='$topic' WHERE id='$id'";
 $query2=mysqli_query($connect,$sql2);
 if(isset($_POST['submit'])){
echo "the data are modified";
  }


else{

echo "something wrong";

}
}
?>  

PHP代码不断产生错误。 问题不在<?php thanx for help

2 个答案:

答案 0 :(得分:2)

乍一看,您似乎错过了以下一行末尾的字符>

<form action="<?php echo $_SERVER['$PHP_SELF'];?>" method="post"

这应该是:

<form action="<?php echo $_SERVER['$PHP_SELF'];?>" method="post">

答案 1 :(得分:2)

.....
.....
<input type="submit" value="refresh">
</form>


<?php  -> Here you need to put `php`
}
....
...