php中的弹出更新[关闭]

Am hi guys currently am having problem updating my myqsl database I have a popup window the updates it there is no error but its not updating what the problem.

here is the popup window php code:

   <?php
session_start();
include("selectDB.php");
myconnection();



            if(isset($_POST['submit']))
            {
                        $myquery="update member set contactno='".$_POST['contactno']."',email='".$_POST['email']."',religion='".$_POST['religion']."',deptid='".$_POST['deptid']."',where memberid='".$_POST['mid']."'";
                        mysql_query($myquery);  


                        echo "Record has been saved.";


            }else{
                        $myquery="select * from member where memberid='".$_SESSION['memberid']."'";
                        $results=mysql_query($myquery);
                        $rs=mysql_fetch_array($results);
                    ?>
                        <form action="editacct.php"  method="post" align="left">
                        <input type="text" name="mid" size="30" value="<?php echo $rs['memberid'];?>" hidden /><br />
                        Contact Number:<br /> <input type="text" name="contactno" size="30" value="<?php echo $rs['contactno'];?>" /><br />
                        E-mail Adress:<br /> <input type="text" name="email" size="30" value="<?php echo $rs['email'];?>"/><br />
                        Religion:<br /> <input type="text" name="religion" size="30" value="<?php echo $rs['religion'];?>"/><br />
                        Address:<br /> <input type="text" name="address" size="30" value="<?php echo $rs['address'];?>"/><br />
                        Department:<br /><select name="deptid" value="<?php echo $rs['deptid'];?>"><br />
                                <option value="">Select</option>
                                <option value="CAH001">Development Communication</option>
                                <option value="CAH002">English</option>
                                <option value="CAH003">Filipino</option>
                                <option value="CAH004">Fine Arts</option>
                                <option value="CAH005">History and Social Sciences</option>
                                <option value="CAH006">Music</option>
                                <option value="CAH007">P.E</option>
                                <option value="CAH008">Psychology</option>
                                <option value="CAH006">Music</option>
                                <option value="CAH007">P.E</option>
                                <option value="CAH008">Psychology</option>
                                <option value="COB001">Accountancy</option>
                                <option value="COB002">Commerce</option>
                                <option value="COB003">Office Administration</option>
                                <option value="COD001">Dentistry</option>
                                <option value="COE001">Elementary Education</option>
                                <option value="COE002">Secondary Education</option>
                                <option value="COH001">Medical Laboratory</option>
                                <option value="COH002">Nutrition and Dietetics</option>
                                <option value="CON001">Nursing</option>
                                <option value="COT001">Theology</option>
                                <option value="CST001">Biology</option>
                                <option value="CST002">Chemistry</option>
                                <option value="CST003">Computer Science</option>
                                <option value="CST004">Computer Technology</option>
                                <option value="CST005">Library Science</option>
                                <option value="CST006">Math and Physics</option>
                                <input type="submit" name="submit" value="Update" />
                        </select>
                        <br />


                        </form>
                        <?php
            }
            ?>

this is the javascript of the popup:

    <script type="text/javascript">

function popup(){
  cuteLittleWindow = window.open("editacct.php", "", "width=700,height=500"); 
}

</script>

This is the link to show the popup

 <div class="clearfix grpelem" id="pu325-3"><!-- group -->
       <a class="nonblock nontext anim_swing clearfix grpelem" id="u325-3" href="javascript:popup()"><!-- content --><p>&nbsp;</p></a>


       <a class="nonblock nontext anim_swing clearfix grpelem" id="u333-6" href="javascript:popup()"><!-- content --><p>ACCOUNT</p><p>INFO</p></a>
 </div>

Remove the trailing comma just before you start the where clause:

deptid='".$_POST['deptid']."',where
                             ^ right there

Having used mysql_query($myquery) or die(mysql_error());

would have signaled the error.

I would like to note that your present code is open to SQL injection. Use mysqli with prepared statements, or PDO with prepared statements, they're much safer.



Add error reporting to the top of your file(s) which will help find errors.

<?php 
error_reporting(E_ALL);
ini_set('display_errors', 1);

// rest of your code

Sidenote: Error reporting should only be done in staging, and never production.


Edit: (conversion from mysql_ to mysqli_, a basic method.

Change your present DB connection to the following.

This is an example taken from http://php.net/manual/en/function.mysqli-connect.php

<?php
$link = mysqli_connect("myhost","myuser","mypassw","mybd") 
        or die("Error " . mysqli_error($link));


// rest of your code

Then change mysql_query($myquery); to mysqli_query($link, $myquery);

$results=mysql_query($myquery); to $results=mysqli_query($link, $myquery);

$rs=mysql_fetch_array($results); to $rs=mysqli_fetch_array($results);

If you have any other functions that start with mysql_, they must be changed to mysqli_.

All mysqli_ functions require DB connection be passed as the first parameter.

This I did to help you out. If this still doesn't work, then I will simply delete this answer.