PHP Mysql Update Query not working -


i have stupid question. before start know using deprecated version of mysql, haven't come around learn mysqli or pdo yet, soon.

i have been working on whole administrative system, , have gotten point i'm creating functions administrators edit other accounts. i've made whole system on 1 page , code becoming little messy (this why i'm getting error).

well i'll begin problem now: have update query doesn't seem working. form follows:

    <form action="" method="post">     <table class="table table-profile">         <thead>             <tr>                 <th colspan="2">                     <h4><?php echo $username; ?> <small><?php echo $fullname; ?></small></h4>                 </th>             </tr>         </thead>         <tbody>             <tr>                 <td colspan="2"><input type="hidden" name="id" value="<?php echo $id; ?>" /></td>             </tr>             <tr>                 <td class="field">username</td>                 <td><input type="text" class="form-control input-xs" name="username" placeholder="" value="<?php echo $username; ?>" /></td>             </tr>             <tr>                 <td class="field">password</td>                 <td><a href="#">password resets must done through james/hamish/cryptic</a></td>             </tr>             <tr>                 <td class="field">full name</td>                 <td><input type="text" class="form-control input-xs" name="fullname" placeholder="" value="<?php echo $fullname; ?>" /></td>             </tr>             <tr>                 <td class="field">email</td>                 <td><input type="text" class="form-control input-xs" name="email" placeholder="" value="<?php echo $email; ?>" /></td>             </tr>             <tr>                 <td class="divider" colspan="2"></td>             </tr>             <tr>                 <td class="field">membership</td>                 <td>                     <select class="form-control input-inline input-xs" name="membership">                         <option value="administrator"<?php if($membership == 'administrator') { echo ' selected'; } ?>>administrator</option>                         <option value="moderator"<?php if($membership == 'moderator') { echo ' selected'; } ?>>moderator</option>                         <option value="supporter"<?php if($membership == 'supporter') { echo ' selected'; } ?>>supporter</option>                         <option value="pm|t"<?php if($membership == 'pm|t') { echo ' selected'; } ?>>platinum modding team</option>                         <option value="paid"<?php if($membership == 'paid') { echo ' selected'; } ?>>paid user</option>                         <option value="free"<?php if($membership == 'free') { echo ' selected'; } ?>>free user</option>                         <option value="none"<?php if($membership == 'none') { echo ' selected'; } ?>>none</option>                     </select>                 </td>             </tr>             <tr>                 <td class="field">plan desription</td>                 <td><input type="text" class="form-control input-xs" name="membership_type" placeholder="membership type" value="<?php echo $membership_type; ?>" /></td>             </tr>             <tr>                 <td class="field">maxtime</td>                 <td>                     <select class="form-control input-inline input-xs" name="membership_maxtime">                         <option value="600"<?php if($membership_maxtime == '600') { echo ' selected'; } ?>>600 seconds</option>                         <option value="1800"<?php if($membership_maxtime == '1800') { echo ' selected'; } ?>>1800 seconds</option>                         <option value="3600"<?php if($membership_maxtime == '3600') { echo ' selected'; } ?>>3600 seconds</option>                         <option value="7200"<?php if($membership_maxtime == '7200') { echo ' selected'; } ?>>7200 seconds</option>                         <option value="4147200"<?php if($membership_maxtime == '4147200') { echo ' selected'; } ?>>4147200 seconds</option>                     </select>                 </td>             </tr>             <tr>                 <td class="field">concurrents</td>                 <td>                     <select class="form-control input-inline input-xs" name="membership_concurrents">                         <option value="1"<?php if($membership_concurrents == '1') { echo ' selected'; } ?>>1 concurrent</option>                         <option value="2"<?php if($membership_concurrents == '2') { echo ' selected'; } ?>>2 concurrents</option>                         <option value="3"<?php if($membership_concurrents == '3') { echo ' selected'; } ?>>3 concurrents</option>                         <option value="4"<?php if($membership_concurrents == '4') { echo ' selected'; } ?>>4 concurrents</option>                         <option value="4147200"<?php if($membership_concurrents == '4147200') { echo ' selected'; } ?>>4147200 concurrents</option>                     </select>                 </td>             </tr>             <tr>                 <td class="field">expiration</td>                 <td><input type="text" class="form-control input-xs" name="membership_expiration" placeholder="membership expiration: (format: yyyy-mm-dd)" value="<?php echo $membership_expiration; ?>" /></td>             </tr>             <tr>                 <td class="divider" colspan="2"></td>             </tr>             <tr>                 <td class="field">ip address</td>                 <td><a href="http://whatismyipaddress.com/ip/<?php echo $location_ip; ?>" target="new"><?php echo $location_ip; ?></td>             </tr>             <tr>                 <td class="divider" colspan="2"></td>             </tr>             <tr>                 <td class="field">warning</td>                 <td>                     <select class="form-control input-inline input-xs" name="warning">                         <option value="0"<?php if($warning == '0') { echo ' selected'; } ?>>level 0 - no warning</option>                         <option value="1"<?php if($warning == '1') { echo ' selected'; } ?>>level 1 - first offence</option>                         <option value="2"<?php if($warning == '2') { echo ' selected'; } ?>>level 2 - strong warning</option>                         <option value="3"<?php if($warning == '3') { echo ' selected'; } ?>>level 3 - last chance</option>                     </select>                 </td>             </tr>             <tr>                 <td class="field">warning note</td>                 <td><textarea class="form-control" rows="4" name="warning_note" placeholder="the warning note displayed after level 1 warning."><?php echo $warning_note; ?></textarea></td>             </tr>             <tr>                 <td class="divider" colspan="2"></td>             </tr>             <tr<?php if ($banned == 'true') { echo ' class="danger"'; } ?>>                 <td class="field"><i class="fa fa-ban"></i> banned</td>                 <td>                     <label class="radio-inline">                         <input type="radio" name="banned" value="false"<?php if ($banned == 'false') { echo ' checked'; } ?> />                         false                     </label>                     <label class="radio-inline">                         <input type="radio" name="banned" value="true"<?php if ($banned == 'true') { echo ' checked'; } ?> />                         true                     </label>                 </td>             </tr>             <tr<?php if ($banned == 'true') { echo ' class="danger"'; } ?>>                 <td class="field">banned reason</td>                 <td><textarea class="form-control" rows="4" name="banned_note" placeholder="reason account ban. (if account banned)"><?php echo $banned_note; ?></textarea></td>             </tr>             <tr>                 <td class="divider" colspan="2"></td>             </tr>             <tr>                 <td class="field">acc created</td>                 <td><?php echo $created; ?></td>             </tr>         </tbody>         <tfoot>             <tr>                 <td colspan="2">                     <button type="submit" name="uploadaccount" class="btn btn-success"><i class="fa fa-upload"></i> upload new changes</button>                     <button type="reset" class="btn btn-warning"><i class="fa fa-refresh"></i> reset fields</button>                 </td>             </tr>         </tfoot>     </table> </form> 

and code update database follows:

    if (isset($_request['uploadaccount'])) {     $id = $post['id'];     $username = $_post['username'];     $fullname = $_post['fullname'];     $email = $_post['email'];      $membership = $_post['membership'];     $membership_type = $_post['membership_type'];     $membership_maxtime = $_post['membership_maxtime'];     $membership_concurrents = $_post['membership_concurrents'];     $membership_expiration = $_post['membership_expiration'];      $warning = $_post['warning'];     $warning_note = $_post['warning_note'];      $banned = $_post['banned'];     $banned_note = $_post['banned_note'];      $account_update = mysql_query("update members set username='$username', fullname='$fullname', email='$email', membership='$membership', membership_type='$membership_type', membership_maxtime='$membership_maxtime', membership_concurrents='$membership_concurrents', membership_expiration='$membership_expiration', warning='$warning', warning_note='$warning_note', banned='$banned', banned_note='$banned_note' id='$id'", $con);      header('location: dashboard.php?admin&accounts&success=account, '.$username.' updated'); } else { } 

i appreciate if let me know doing wrong. thank in advance do.

dont use deprecated mysql_* use pdo.

here have example.

$pdo    = new pdo ($server, $user, $password); $query  = 'update members set username= :username, fullname= :fullname'; $stmt   = $pdo -> prepare($query); $stmt->bindparam(":username", $username, pdo::param_str); $stmt->bindparam(":fullname", $fullname, pdo::param_str); $stmt->execute(); 

with pdo can bind params query.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -