dsw7547 2014-08-25 23:24
浏览 90

使用$ id更新内容不起作用

I'm curious as to where my issue seems to be... I tried to use the $id=$_GET['id'] command in order to collect the id and allow my sql row to be updated. Can anyone help me and see what it is I'm doing wrong?

Here's my database line up:

||idtest||testing

and the current update PHP:

<?php
  include("database_conn_test.php");
?>
<?php
  //select database table
          $sql = "SELECT testing FROM test";
          $queryresult = mysql_query($sql) or die (mysql_error());

        //Request Values
          while ($res = mysql_fetch_array($queryresult)){
            $algemeneVoorwaarden = $res['testing'];
          }
          if(mysql_num_rows($queryresult) <= 0) {
            echo("");
          }

  if(isset($_POST['update'])){
    $id = $_GET['id'];
    $res= mysql_query("SELECT * FROM test WHERE idtest=$id");
    $avID= mysql_fetch_array($res);

    $algemeneVoorwaarden = mysql_real_escape_string($_POST['testing']);

    $updateAV = "UPDATE test SET testing=$algemeneVoorwaarden WHERE idtest=$avID";
    $result = mysql_query($updateAV);
  }
?>

And last but not least the HTML:

    <div class="tinyMCEWrapper">
  <script src="tinymce/tinymce.min.js"></script>
  <script type="text/javascript">tinymce.init({selector: "textarea"});</script>
  <form method="post" action="test.php?id=<?php echo $id; ?>">
    <textarea name="testing" id="content" class="algemeneAdmin" style="width:100%"><?php echo $algemeneVoorwaarden; ?>
    </textarea>
    <input type="hidden" name="id" value = "<?php echo $id; ?>">
    <button type="submit">Post</button>
  </form>
</div>

UPDATE: I have figured out the area of incidence, but not how to fix it. I am doing something wrong with $id as it never receives a value...

  • 写回答

3条回答 默认 最新

  • douxun7992 2014-08-25 23:33
    关注

    Your form is submitting using POST. This means that your $_GET['id'] should be a $_POST['id']. Or you can change your form from method="post" to method="get" and it will use $_GET instead of $_POST

    评论

报告相同问题?

悬赏问题

  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退