ghqwerty Posted October 4, 2008 Share Posted October 4, 2008 mysql_query("UPDATE members set gender = '".$gender."' and profile = '".$profile."' where id = '".$_SESSION['id']."'") or die(mysql_error()); thats the code im useing echo $who_result['gender']; and thats what im using to call the data however it isnt actually adding or updating the database Link to comment https://forums.phpfreaks.com/topic/126990-update-gender-and-profile/ Share on other sites More sharing options...
Brian W Posted October 4, 2008 Share Posted October 4, 2008 Why do you need to update GENDER? Link to comment https://forums.phpfreaks.com/topic/126990-update-gender-and-profile/#findComment-656911 Share on other sites More sharing options...
Brandon Jaeger Posted October 4, 2008 Share Posted October 4, 2008 More code would help, but try this: mysql_query("UPDATE members SET gender = '".$gender."' AND profile = '".$profile."' WHERE id = ".$_SESSION['id']) or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/126990-update-gender-and-profile/#findComment-656913 Share on other sites More sharing options...
ghqwerty Posted October 4, 2008 Author Share Posted October 4, 2008 the reason i would need to do this is because the gender is initially 'not available' then the user can change it to whatever they are ok ill post all the code as that still doesnt work $id = $_SESSION['id']; $who = "select * from members where id = '".$userid."'"; $who_resulted = mysql_query($who); $who_result = mysql_fetch_array($who_resulted); $username = $who_result['username']; //make the table if($edit == "yes"){ echo "<table id='profileedit' height='20%' width='35%' border='1'> <tr> <td colspan='3'> <center> player ".$username." </center> </td> </tr> <tr> <td colspan='2'> <center> statistics </center> </td> <td> profile </td> </tr> <tr> <td> gender : </td> <td> <form method='post' action='stats.php?uid=$userid'> male : <input type='radio' name='gender' value='male'> female : <input type='radio' name='gender' value='female'> </td> <td rowspan='2'> <TEXTAREA NAME='profile' COLS='20' ROWS='10'></TEXTAREA> </td> </tr> <tr> <td colspan='2'> <input type='submit' name='editprofile' value='save changes'> </form> </td> </tr> </table> "; if(isset($_POST['editprofile'])){ $gender = $_POST['gender']; $profile = $_POST['profile']; $insert = "UPDATE members set gender = '".$gender."' where id = '".$_SESSION['id']."'"; mysql_query("UPDATE members SET gender = '".$gender."' AND profile = '".$profile."' WHERE id = ".$_SESSION['id']) or die(mysql_error()); } }else{ echo "<table id='profile' height='20%' width='35%' border='1'> <tr> <td colspan='3'> <center> player ".$username." </center> </td> </tr> <tr> <td colspan='2'> <center> statistics </center> </td> <td> profile </td> </tr> <tr> <td> level : </td> <td> ". $who_result['rank'] ." </td> <td rowspan='5'> profile </td> </tr> <tr> <td> name : </td> <td> ". $who_result['username']." </td> </tr> <tr> <td> class : </td> <td> ".$who_result['class']." </td> </tr> <tr> <td> gender : </td> <td>"; if($who_result['gender'] != 'male' && $who_result['gender'] != 'female'){ echo "not available"; }else{ echo $who_result['gender']; } echo " </td> </tr>"; if($userid == $_SESSION['id']){ echo "<tr><td colspan='2'><a href='stats.php?uid=$userid&edit=yes'>edit profile</a></td></tr>"; } echo "</table>"; } Link to comment https://forums.phpfreaks.com/topic/126990-update-gender-and-profile/#findComment-656920 Share on other sites More sharing options...
ghqwerty Posted October 4, 2008 Author Share Posted October 4, 2008 bump sorry for being imptient but i kinda need to know soon sorry im going out in a bit Link to comment https://forums.phpfreaks.com/topic/126990-update-gender-and-profile/#findComment-656980 Share on other sites More sharing options...
JasonLewis Posted October 4, 2008 Share Posted October 4, 2008 Try this for the query: mysql_query("UPDATE members SET gender = '".$gender."', profile = '".$profile."' WHERE id = '".$_SESSION['id']."'") or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/126990-update-gender-and-profile/#findComment-656981 Share on other sites More sharing options...
ghqwerty Posted October 4, 2008 Author Share Posted October 4, 2008 Try this for the query: mysql_query("UPDATE members SET gender = '".$gender."', profile = '".$profile."' WHERE id = '".$_SESSION['id']."'") or die(mysql_error()); still no luck Link to comment https://forums.phpfreaks.com/topic/126990-update-gender-and-profile/#findComment-656986 Share on other sites More sharing options...
ghqwerty Posted October 4, 2008 Author Share Posted October 4, 2008 hmm just took a step back and slowly thought it through and fixed it what its doing is because ive made the action action='stats.php?uid=$userid' when i click submit it goes back to the stats page so if(isset($_POST['editprofile'])){ etc will never happen because when its submitted it goes to the previous page i fixed this by making the action action='stats.php?uid=$userid&edit=yes' although could i just put the update code inside my other block so that when the user updates it takes him back to his profile not the edit ?? Link to comment https://forums.phpfreaks.com/topic/126990-update-gender-and-profile/#findComment-656994 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.