mysql_query 会话期间未更新数据库

mysql_query not updating database during session

我目前使用会话登录,我希望用户能够更新他们的信息。但是在提交时没有任何反应。该会话有效,因为当我检查 iduser 电子邮件和密码时回显。我想我可能写错了查询或者我使用的会话不正确。有人可以解释为什么数据库中没有更新吗?

    <?php
session_start();
include "connect.php";
include "header.php";
$iduser=$_SESSION['logged_in']['iduser'];
$sql = mysql_query("SELECT * FROM `profile` WHERE `iduser` = '$iduser' ");      
while($row = mysql_fetch_array($sql)){
    $iduser = $row['iduser'];
    $password = $row['password'];   
    $email = $row['email'];                     
    $fnlname = $row['fnlname'];     
    $username = $row['username'];
    $joineddate = $row['joineddate'];                       
    $gender = $row['gender'];   
    $age = $row['age'];
    $location = $row['location'];
    $website = $row['website'];                         
}                       
echo "$iduser $password $email";                            
$form1 = <<<EOT
<div id="homebox1">
    <div id="logohome">
        <h2>Welcome</h2></br>
    </div>
    <div id="signupcolumn1">
        <p>Please fillout your info</p>
        <form id="signup2" action="signup_part2.php" method="POST">
            <p><input name="fnlname" placeholder="First and Last Name" type="text" size="50" required>*</br>
                <input name="username" placeholder="Username" type="text" size="50" required>*</br>         
                <input name="age" placeholder="Your Age" type="" size="50" required>*</br></p>
                <p><input style="text-align:left;" type="radio" name="gender" value="male"/>Male</br>
                    <input style="text-align:left;" type="radio" name="gender" value="female"/>Female</br>
                    <input style="text-align:left;" type="radio" name="gender" value="blank"/>Leave Blank</br></p>
                    <p><input name="location" placeholder="Location" type="" size="50" >Opt.</br>
                        <input name="website" placeholder="Website" type="" size="50">Opt. </br></p>
                        <input name="joineddate" placeholder="joineddate" type="hidden" size="50">
                        <input type="submit" name="submita" value="Next"> 
                    </div>
                </form>

EOT;

if(isset($_POST['submita'])){
//perform verification
        $fnlname = $_POST['fnlname'];
        $username = $_POST['username'];
        $age = $_POST['age'];
        $gender = $_POST['gender'];
        $location = $_POST['location'];
        $website = $_POST['website'];
        $joineddate = $_POST['joineddate'];
        $iduser=$_SESSION['logged_in']['iduser'];
        $fnlname = mysql_escape_string($fnlname);
        $username = mysql_escape_string($username);
        $age = mysql_escape_string($age);
        $gender = mysql_escape_string($gender);
        $location = mysql_escape_string($location);
        $website = mysql_escape_string($website);
        $sql1 = mysql_query("SELECT * FROM `profile` WHERE `username` = '$username' ");

        if(mysql_num_rows($sql1) > 0){
            echo "Sorry, that username already exists!";
        }else{  
            mysql_query("UPDATE profile SET fnlname='$fnlname' joineddate='$joineddate' gender='$gender' age='$age' location='$location' website='$website' WHERE iduser=$iduser ");
        }

}else{
    echo $form1;
}
?>

您的查询应该是这样的

UPDATE profile SET fnlname='$fnlname', joineddate='$joineddate', gender='$gender', age='$age' ,location='$location', website='$website' WHERE iduser='$iduser'

你错过了逗号 如果$iduser 是一个字符串你必须用单引号封装