本帖最后由 xuzuning 于 2012-05-19 15:30:10 编辑

解决方案 »

  1.   

    你沒有數據庫的結構,如果代碼沒有問題,也是找不出哪裏出錯的啊,你就把修改的php代碼發上來好了,因爲如果讓別人去下代碼還要解壓啥的,基本上沒多少人願意這麼做的。
      

  2.   

    啊 對不起 這是修改頁的代碼<?php session_start();?>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <link href="CSS/style.css" rel="stylesheet">
    <style type="text/css">
    <!--
    .style1 {color: #FF6600}
    -->
    </style>
    </head>
    <script language="javascript">
    function check(form){
    if(form.course_code.value==""){
    alert("Please enter the Course ID!");form.course_code.focus();return false;
    }
    if(form.course_name.value==""){
    alert("Please enter the Course Name!");form.course_name.focus();return false;
    }
    if(form.assessment.value==""){
    alert("Please enter the Teaching Strategies!");form.assessment.focus();return false;
    }
    form.submit();
    }
    </script>
    <body>
    <table width="776" border="0" align="center" cellpadding="0" cellspacing="0" class="tableBorder">
      <tr>
        <td>
    <?php include("navigation.php");?>
    </td>
      </tr>
    <td>
    <table width="100%"  border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td valign="top" bgcolor="#FFFFFF"><table width="99%" height="475"  border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" class="tableBorder_gray">
      <tr>
        <td height="473" align="center" valign="top" style="padding:5px;"><table width="98%" height="463"  border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td height="22" valign="top" class="word_orange">Current Location: Discipline, file management> Modify Course Information >>></td>
          </tr>
          <tr>
            <td height="441" align="center" valign="top"><table width="100%" height="421"  border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td height="421" align="center" valign="top">
    <form name="form1" method="post" action="diisc_modify_ok.php">
    <?php
    include("conn/conn.php");
    $sql=mysql_query("select book.course_code,book.id as courseid,book.course_name,bt.typename,book.typeid,book.learning_Content,book.st_numb,book.teaching_strategie,book.coursecase,pb.college_name,book.assessment,book.textbook_Reference,bc.name from tb_module_information book join tb_discipline bt on book.typeid=bt.id join tb_college pb on book.st_numb=pb.st_numb join tb_course bc on book.coursecase=bc.id where book.id=$_GET[id]");
    $info=mysql_fetch_array($sql);
    ?>
        <input type="hidden" name="bid" value="<?php echo $info[book.id];?>">
        <table width="600" height="397"  border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
          <tr>
            <td width="173" align="center">Course ID:</td>
            <td width="427" height="33">
              <input name="course_code" type="text" id="course_code" value="<?php echo $info[course_code];?>"></td>
          </tr>
          <tr>
            <td align="center">Course Name:</td>
            <td height="35"><input name="course_name" type="text" id="course_name" value="<?php echo $info[course_name];?>" size="50">
              <span class="style1">*</span></td>
          </tr>
          <tr>
            <td height="35" align="center">Discipline Type:</td>
            <td>
    <select name="typeId" class="wenbenkuang" id="typeId">
    <?php 
    $sql1=mysql_query("select * from tb_discipline");
    $info1=mysql_fetch_array($sql1);
    do{
    ?> 
            <option value="<?php echo $info1[id];?>" <?php if($info1[id]==$info[typeid]){?> selected <?php }?>><?php echo $info1[typename];?></option>
    <?php }while($info1=mysql_fetch_array($sql1));?> 
            </select> </td>
          </tr>
          <tr>
            <td align="center">Learning Contents:</td>
            <td><input name="learning_Content" type="text" id="learning_Content" value="<?php echo $info[learning_Content];?>" size="60"></td>
          </tr>
          <tr>
            <td height="36" align="center">Learning Outcomes:</td>
            <td><input name="teaching_strategie" type="text" id="teaching_strategie" value="<?php echo $info[teaching_strategie];?>" size="40"></td>
          </tr>
          <tr>
            <td height="34" align="center">Attend regional:</td>
            <td>
    <select name="st_numb" class="wenbenkuang">
    <?php
    $sql2=mysql_query("select * from tb_college");
    $info2=mysql_fetch_array($sql2);
    do{
    ?> 
            <option value="<?php echo $info2[st_numb];?>"<?php if($info2[st_numb]==$info[st_numb]){?> selected <?php }?>><?php echo $info2[college_name];?></option>
    <?php }while($info2=mysql_fetch_array($sql2));?> 
            </select> </td>
          </tr>
          <tr>
            <td align="center">Teaching Strategies:</td>
            <td><input name="assessment" type="text" id="assessment" value="<?php echo $info[assessment];?>">
            (May increase)</td>
          </tr>
          <tr>
            <td align="center">Assessment:</td>
            <td><input name="textbook_Reference" type="text" id="textbook_Reference" value="<?php echo $info[textbook_Reference];?>"></td>
          </tr>
          <tr>
            <td height="34" align="center">Textbook&References:</td>
            <td><select name="coursecaseid" class="wenbenkuang" id="coursecaseid">
    <?php
    $sql3=mysql_query("select * from tb_course");
    $info3=mysql_fetch_array($sql3);
    do{
    ?> 
              <option value="<?php echo $info3[id];?>"<?php if($info3[id]==$info[coursecase]){?> selected <?php }?>><?php echo $info3[name];?></option>
    <?php }while($info3=mysql_fetch_array($sql3));?> 
            </select>
              <input name="operator" type="hidden" id="operator" value="<?php echo $info3[name];?>"></td>
          </tr>
          <tr>
            <td colspan="2" align="center"><input name="Submit" type="submit" class="btn_grey" value="Save" onClick="return check(form1)">&nbsp;
    <input name="Submit2" type="button" class="btn_grey" value="Back" onClick="history.back();"></td>
            </tr>
        </table>
    </form> </td>
      </tr>
    </table></td>
          </tr>
        </table></td>
      </tr>
    </table><?php include("copyright.php");?></td>
      </tr>
    </table>
    </td>
      </tr>
    </table>
    </body>
    </html>
    然後他會彈出"成功修改"<?php 
    session_start();
    include("Conn/conn.php");
    $bid=$_POST[bid];
    $operator=$_SESSION["admin_name"];
    $course_code=$_POST["course_code"];
    $course_name=$_POST["course_name"];
    $typeid=$_POST["typeId"];
    $learning_Content=$_POST["learning_Content"];
    $teaching_strategie=$_POST["teaching_strategie"];
    $st_numb=$_POST["st_numb"];
    $assessment=$_POST["assessment"];
    $textbook_Reference=$_POST["textbook_Reference"];
    $coursecase=$_POST["coursecaseid"];
    $inTime=date("Y-m-d");
    $query=mysql_query("update tb_module_information set course_code='$course_code', course_name='$course_name' , typeid='$typeid', learning_Content='$learning_Content', teaching_strategie='$teaching_strategie', st_numb='$st_numb' , assessment='$assessment' , textbook_Reference='$textbook_Reference' , coursecase='$coursecase', inTime='$inTime', operator='$operator' where id=$bid");
    echo "<script language='javascript'>alert('Course information is successfully modified!');history.back();</script>";
    ?>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    到底是否因部份欄位名不合呢?
      

  3.   

    對不起 現用回簡體發文求救!简单而严重的问题!看不到的错误!附原档!
    如图所见使用APPSERV制作的教学修改栏位名称后
    就导致到修改功能失效
    Log:root PW:1234
    如图登入后 点击此栏
    ht tp:// p13.freep.cn/p.aspx?u=v20_p13_photo_1205191502575224_0.png
    选择 CHANGE
    ht tp:// p13.freep.cn/p.aspx?u=v20_p13_photo_1205191503105157_0.png
    更改内文后再按SAVE 会弹出"你成功修改"的英文但实际没有内文依旧
    ht tp:// p13.freep.cn/p.aspx?u=v20_p13_photo_1205191503202450_0.png我猜问题应与SQL有关原档:
    ht tp://115.com/file/e7xogco5#WD.zip======================================================================对不起这是修改页的代码<?php session_start();?>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <link href="CSS/style.css" rel="stylesheet">
    <style type="text/css">
    <!--
    .style1 {color: #FF6600}
    -->
    </style>
    </head>
    <script language="javascript">
    function check(form){
    if(form.course_code.value==""){
    alert("Please enter the Course ID!");form.course_code.focus();return false;
    }
    if(form.course_name.value==""){
    alert("Please enter the Course Name!");form.course_name.focus();return false;
    }
    if(form.assessment.value==""){
    alert("Please enter the Teaching Strategies!");form.assessment.focus();return false;
    }
    form.submit();
    }
    </script>
    <body>
    <table width="776" border="0" align="center" cellpadding="0" cellspacing="0" class="tableBorder">
      <tr>
        <td>
    <?php include("navigation.php");?>
    </td>
      </tr>
    <td>
    <table width="100%"  border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td valign="top" bgcolor="#FFFFFF"><table width="99%" height="475"  border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" class="tableBorder_gray">
      <tr>
        <td height="473" align="center" valign="top" style="padding:5px;"><table width="98%" height="463"  border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td height="22" valign="top" class="word_orange">Current Location: Discipline, file management> Modify Course Information >>></td>
          </tr>
          <tr>
            <td height="441" align="center" valign="top"><table width="100%" height="421"  border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td height="421" align="center" valign="top">
    <form name="form1" method="post" action="diisc_modify_ok.php">
    <?php
    include("conn/conn.php");
    $sql=mysql_query("select book.course_code,book.id as courseid,book.course_name,bt.typename,book.typeid,book.learning_Content,book.st_numb,book.teaching_strategie,book.coursecase,pb.college_name,book.assessment,book.textbook_Reference,bc.name from tb_module_information book join tb_discipline bt on book.typeid=bt.id join tb_college pb on book.st_numb=pb.st_numb join tb_course bc on book.coursecase=bc.id where book.id=$_GET[id]");
    $info=mysql_fetch_array($sql);
    ?>
        <input type="hidden" name="bid" value="<?php echo $info[book.id];?>">
        <table width="600" height="397"  border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
          <tr>
            <td width="173" align="center">Course ID:</td>
            <td width="427" height="33">
              <input name="course_code" type="text" id="course_code" value="<?php echo $info[course_code];?>"></td>
          </tr>
          <tr>
            <td align="center">Course Name:</td>
            <td height="35"><input name="course_name" type="text" id="course_name" value="<?php echo $info[course_name];?>" size="50">
              <span class="style1">*</span></td>
          </tr>
          <tr>
            <td height="35" align="center">Discipline Type:</td>
            <td>
    <select name="typeId" class="wenbenkuang" id="typeId">
    <?php 
    $sql1=mysql_query("select * from tb_discipline");
    $info1=mysql_fetch_array($sql1);
    do{
    ?> 
            <option value="<?php echo $info1[id];?>" <?php if($info1[id]==$info[typeid]){?> selected <?php }?>><?php echo $info1[typename];?></option>
    <?php }while($info1=mysql_fetch_array($sql1));?> 
            </select> </td>
          </tr>
          <tr>
            <td align="center">Learning Contents:</td>
            <td><input name="learning_Content" type="text" id="learning_Content" value="<?php echo $info[learning_Content];?>" size="60"></td>
          </tr>
          <tr>
            <td height="36" align="center">Learning Outcomes:</td>
            <td><input name="teaching_strategie" type="text" id="teaching_strategie" value="<?php echo $info[teaching_strategie];?>" size="40"></td>
          </tr>
          <tr>
            <td height="34" align="center">Attend regional:</td>
            <td>
    <select name="st_numb" class="wenbenkuang">
    <?php
    $sql2=mysql_query("select * from tb_college");
    $info2=mysql_fetch_array($sql2);
    do{
    ?> 
            <option value="<?php echo $info2[st_numb];?>"<?php if($info2[st_numb]==$info[st_numb]){?> selected <?php }?>><?php echo $info2[college_name];?></option>
    <?php }while($info2=mysql_fetch_array($sql2));?> 
            </select> </td>
          </tr>
          <tr>
            <td align="center">Teaching Strategies:</td>
            <td><input name="assessment" type="text" id="assessment" value="<?php echo $info[assessment];?>">
            (May increase)</td>
          </tr>
          <tr>
            <td align="center">Assessment:</td>
            <td><input name="textbook_Reference" type="text" id="textbook_Reference" value="<?php echo $info[textbook_Reference];?>"></td>
          </tr>
          <tr>
            <td height="34" align="center">Textbook&References:</td>
            <td><select name="coursecaseid" class="wenbenkuang" id="coursecaseid">
    <?php
    $sql3=mysql_query("select * from tb_course");
    $info3=mysql_fetch_array($sql3);
    do{
    ?> 
              <option value="<?php echo $info3[id];?>"<?php if($info3[id]==$info[coursecase]){?> selected <?php }?>><?php echo $info3[name];?></option>
    <?php }while($info3=mysql_fetch_array($sql3));?> 
            </select>
              <input name="operator" type="hidden" id="operator" value="<?php echo $info3[name];?>"></td>
          </tr>
          <tr>
            <td colspan="2" align="center"><input name="Submit" type="submit" class="btn_grey" value="Save" onClick="return check(form1)">&nbsp;
    <input name="Submit2" type="button" class="btn_grey" value="Back" onClick="history.back();"></td>
            </tr>
        </table>
    </form> </td>
      </tr>
    </table></td>
          </tr>
        </table></td>
      </tr>
    </table><?php include("copyright.php");?></td>
      </tr>
    </table>
    </td>
      </tr>
    </table>
    </body>
    </html>
    =======================================================然后他会弹出“成功修改”<?php 
    session_start();
    include("Conn/conn.php");
    $bid=$_POST[bid];
    $operator=$_SESSION["admin_name"];
    $course_code=$_POST["course_code"];
    $course_name=$_POST["course_name"];
    $typeid=$_POST["typeId"];
    $learning_Content=$_POST["learning_Content"];
    $teaching_strategie=$_POST["teaching_strategie"];
    $st_numb=$_POST["st_numb"];
    $assessment=$_POST["assessment"];
    $textbook_Reference=$_POST["textbook_Reference"];
    $coursecase=$_POST["coursecaseid"];
    $inTime=date("Y-m-d");
    $query=mysql_query("update tb_module_information set course_code='$course_code', course_name='$course_name' , typeid='$typeid', learning_Content='$learning_Content', teaching_strategie='$teaching_strategie', st_numb='$st_numb' , assessment='$assessment' , textbook_Reference='$textbook_Reference' , coursecase='$coursecase', inTime='$inTime', operator='$operator' where id=$bid");
    echo "<script language='javascript'>alert('Course information is successfully modified!');history.back();</script>";
    ?>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">到底是否因部份栏名的名不合呢?
      

  4.   

    修改成  $query=mysql_query("update tb_module_information.....") or die(mysql_error());
    看看具体是什么错误
      

  5.   

    你这里判断都没有加,不管成功与否都将弹出提示框,如#7楼所说:$sql="update tb_module_information set course_code='$course_code', course_name='$course_name' , typeid='$typeid', learning_Content='$learning_Content', teaching_strategie='$teaching_strategie', st_numb='$st_numb' , assessment='$assessment' , textbook_Reference='$textbook_Reference' , coursecase='$coursecase', inTime='$inTime', operator='$operator' where id=$bid";
    $query=mysql_query($sql);
    if(!$query)
        die("SQL:{$sql}<br>Error:".mysql_error());
    if(mysql_affected_rows() > 0){
        echo "<script language='javascript'>alert('Course information is successfully modified!');history.back();</script>";
    }else{
        echo "<script language='javascript'>alert('Course information is unsuccessfully modified!');history.back();</script>";
    }
      

  6.   

    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '....' at line 1是版本問題嗎?
    不明白 求解答 感謝
      

  7.   

    按#9写法,将每一条sql的执行语句打出来,还有error提示贴全了,……里面是重点
      

  8.   

    SQL:update tb_module_information set course_code='3518', course_name='Multimedia & Entertainment Technology - Web Development' , type_id='1', learning_Content='Learning technologies such as PHP, JAVA, MYSQL', teaching_strategie='Understand the network architecture to create a promotional website', st_numb='7-111' , assessment='Multimedia Hearing Teaching and Self-management Learning Strategies' , textbook_Reference='Most can be completed within 30 working days' , coursecase='46', inTime='2012-05-21', operator='MR' where id=
    Error:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1ERROR 回答跟上一個一樣...
      

  9.   

    看明白了吧,sql语句有错误,条件判断的id没有值,看看你在哪接收的这个id,然后顺藤摸瓜
      

  10.   


    $bid=$_POST[bid];
    #是不是要改成:
    $bid=$_POST['bid'];
    #你的$bid没有值,不信你输出一下:
    echo $bid;
    #还有你确定这个bid使用post传来的?而不是get方式传来的参数?,如果是参数:
    $bid = $_GET['bid'];
      

  11.   

    只能確定問題的確在bid處 但跟BID相關的只有四項
    那問題就應該跟DISS_MODIFY.PHP下的book.id有關了
    <input type="hidden" name="bid" value="<?php echo $info[book.id];?>">
    發了個私信 可以請你幫忙看一下嗎? 很感謝你
      

  12.   

    这是什么写法??
    请问你的info内容是什么模样的?你要得到的数据是什么$info[book.id];
      

  13.   

    请问你的info内容是什么模样的?你要得到的数据是什么
    就是通知修改 但好像在BOOK.ID後有某些欄名有問題感應不到致条件判断的id没有值發了個私信給您 
    請幫幫忙看看到底BOOK.ID後的是什麼 
    我真的沒有能力去找 
    真的很感謝你的回覆
      

  14.   

    你print_r($info);
    然后把结果发出来我看一下另外 $info[book.id]; 这个写法是错的吧?可以这么写么?
      

  15.   

    我抽空看了你的源码,恢复了你的数据库,找到了你登录系统的口令但是仍然没有搞清楚,你希望解决的问题在哪里
    错误太多,没有时间一一修复你最好抽取相关代码,形成测试例。这样便于缩小问题的范围比如你的 diisc_Modify.php
    已经就有了 
    Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in D:\AMP\web\WD\diisc_Modify.php on line 50
    很难设想表单页 diisc_modify_ok.php 不出问题
      

  16.   

    别急,你把数据库用phpmyadmin导出来sql文档,然后传到网盘.或者发给我gmail
    今晚9点后帮你死磕 解决问题.gtalk 发给你,到时候联系我.
      

  17.   

    這是在正式修改頁DISS_MODIFY.PHP(即第三張圖片)的
    <input type="hidden" name="bid" value="<?php echo $info[book.id];?>">
    得出的:Array ( [0] => 3518 [course_code] => 3518 [1] => 5 [courseid] => 5 [2] => Multimedia & Entertainment Technology - Web Development [course_name] => Multimedia & Entertainment Technology - Web Development [3] => Web Technology [typename] => Web Technology [4] => 1 [typeid] => 1 [5] => Learning technologies such as PHP, JAVA, MYSQL [learning_Content] => Learning technologies such as PHP, JAVA, MYSQL [6] => 7-121 [st_numb] => 7-121 [7] => Understand the network architecture to create a promotional website [teaching_strategie] => Understand the network architecture to create a promotional website [8] => 46 [coursecase] => 46 [9] => Ive(lwl) [college_name] => Ive(lwl) [10] => Multimedia Hearing Teaching and Self-management Learning Strategies [assessment] => Multimedia Hearing Teaching and Self-management Learning Strategies [11] => Most can be completed within 30 working days [textbook_Reference] => Most can be completed within 30 working days [12] => English Language [name] => English Language ) 
    另外 $info[book.id]; 这个写法是错的吧?可以这么写么?在另一個版本試過 可運行 
    之後開新檔修改了欄名 之後就發生了這些事了.
      

  18.   

    感謝二位的回答 已發了卵信 詳附原文檔 SQL資料等
    感謝你們的幫助 謝謝
      

  19.   

    1个小时...先是看了一下原版..无法看下去,表都有缺的再看修改版 错误也是一大堆... 
    从登录开始..
    目前一直修正到 你上面说的点修改后没有成功修改问题。
    其他我就没看啦自己慢慢看吧.提示一下
    以后别再这么写 $info[somecode];
    应该正确的书写成 $info['somecode'];修改后的压缩包已经发给你,注意 数据库conn.php文件密码我已经清空,自己重新改回去.另外数据库里有个表的主键没创建,忘记哪个了自己检查一下.
      

  20.   

    我试过了,这种写法就是错误的:<?php
    $array = array("bid"=>array("id"=>1,2,3));
    ?>
    <input type="text" name="name1" value="<?=$array[bid.id]?>"/>
      <!--
      <br /><b>Notice</b>:  Use of undefined constant bid - assumed 'bid' in <b>\path\test_csdn\test13.php</b> on line <b>17</b><br /><br /><b>Notice</b>:  Use of undefined constant id - assumed 'id' in <b>\path\test_csdn\test13.php</b> on line <b>17</b><br /><br /><b>Notice</b>:  Undefined index: bidid in <b>\path\test_csdn\test13.php</b> on line <b>17</b><br />
      -->如果你的$info是一个二维数组,应该这样写:<?php
    $array = array("bid"=>array("id"=>1,2,3));
    ?>
      <input type="text" name="name1" value="<?=$array['bid']['id']?>"/>
      <!-- 源码
       <input type="text" name="name1" value="1"/>
      -->另,根据#22的描述:
    你的$info中根本就没有bookid这一项,你肯定搞错对象了。
    再根据#12的描述:
    得出结论:你的数据库中的tb_module_information表要么没有id这一字段,要么id实际上是courseid字段。即,要根据courseid字段值来修改tb_module_information的内容。那么你的页面就应该是:<input type="hidden" name="bid" value="<?php echo $info['courseid'];?>">总结:仔细检查你的数据库表,看其和你的sql执行语句是否字段对应,然后再将需要的值放于页面。