lundi 27 juin 2016

MySQL Update Syntax won't update changes in MySQL Table [duplicate]

This question already has an answer here:

I have a problem with my php code. It seems that the update syntax doesn't update the table. I have tried everything, i even set the values manually, you know writting the name and the group and it doesn't update anyway. I can't figure out what the problem might be, i'm getting no error nothing, it works exactly how i wrote just that it doesn't update the mysql table. I've checked to see if there are "reserved names" for phpmyadmin but nothing. I'm staring at this code for 2 hours now.

The $action == remove_member is just a thing so when i press an link it shows me this script and html code, nothing too fancy, but something that works, i tried without this thing too, and same result.

Thank's if you can help me.

EDIT: Problem solved, i misstyped the variable $account_name in the syntax.

    <?php if($action == "remove_member") { ?>
            <!-- Remove member by $_GET method -->
            <div class="col-md-6">
                <div class="panel panel-forum">
                  <div class="panel-heading"><i class="fa fa-minus"></i> Remove member</div>
                  <form method="post">
                  <?php 
                  $account_name = stripslashes(mysql_real_escape_string($_GET['account_name']));
                  $group_name = stripslashes(mysql_real_escape_string($_GET['group_name']));

                  if(isset($_POST['remove_member']))
                  {
                    $account_group = "Users";
                    if(mysql_query("UPDATE wb_accounts SET account_group='Users' WHERE account_name='".$acount_name."'"))
                    {
                        header('Location: group_manager.php');
                    }
                    else
                    {
                        header('Location: group_manager.php?action=remove_member&err=Error while trying removing the member !');
                    }
                  }

                  ?>
                  <div class="panel-body">
                    <p><?php echo htmlentities($_GET['err']); ?></p>
                    <p>You're about to remove the next user: </p>
                    <p><i class="fa fa-user"></i> Account name: <b> <?php echo htmlentities($account_name); ?> </b><br>
                    <i class="fa fa-users"></i> Current group: <b> <?php echo htmlentities($group_name); ?></b>
                    </p>
                    <p>Once deleted, default group 'Users' will be apply on the account.</p>
                    <br><p><i> Are you sure you want to delete him anyway? </i></p>

                    <p><input type="submit" name="remove_member" class="btn btn-md btn-primary" value="Yes"/> <a href="group_manager.php" class="btn btn-md btn-primary"> No</a></p>
                    </form>
                </div>
                </div>
            </div>
            <?php } ?>

Aucun commentaire:

Enregistrer un commentaire