php - Javascript Not Updating Database -


i have edit profile, user's profile. well, javascript seems getting value of age's form. php file getting age, no others , it's not updating database.

javascript:

function updateprofile() { var newage = $("#newage").val(); var newimage = $("#newimage").val();     var newbio = $("#newbio").val();     var datastring = 'newage=' + newage || 'newimage=' + newimage || 'newbio=' + newbio;     if (newbio.length , newage.length , newimage.length == 0) {     $('#required').fadein(300);     $('#mask').fadein(300);      } else {     $.ajax({         type: "post",         url: "update_profile.php",         data: datastring,         cache: false,         success: function (updateprofile) {             $('#editinfo').hide();             $("#updatedprofile").html(updateprofile);             $("#updatedprofile").fadein('slow');             $("#age").html('age: ' + newage);             $('#image').html('<img src="' + newimage +'" width="150" height="100" />');                                                      }     });    } } 

here's update_profile.php file:

<?php session_start() ?> <?php include 'connect.php' ?>            <?php         $newimage = $_post['newimage'];         $newbio = $_post['newabout'];         $newage = $_post['newage'];                      $update = "update members set bio=(".$newbio.") age=(".$newage.") image=(".$newimage.") id='".$id."'";             $res = mysql_query($update);             echo 'success: profile updated!<br />';             echo $update . '<br />';       ?> 

html:

<input type="text" id="newage" value="<?php echo $age ?>" maxlength="2" /> <input type="text" id="newimage" value="<?php echo $image ?>" maxlength="500" /> <textarea id="newbio" style="width: 500; max-width: 500; height: 100; max-height: 150;"><?php echo $bio ?></textarea> <input type="submit" value="update profile" onclick="updateprofile()" /> 

the code update outputs this:

success: profile updated! update members set bio=() age=(18) image=() id='1' 

try instead:

$.ajax({     ...     data: { newimage: newimage,             newage: newage,             newbio: newbio }    ... }); 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -