scmeeker Posted June 30, 2010 Share Posted June 30, 2010 I'm having trouble with the form updating. It seems I have all this code right but its still not updating the table. I have a form set up that pulls the information that's already in the table and then it can be edited (hence the need for updating) but when the update button is clicked, nothing is updated or changed. Now I'm working with session variables and wondering if they're being passed when the update button is clicked. Here is the form: <form action="artist_profile_update.php" method="post" name="update"> <br /> <span class="titles">A bit about you:</span><br /> <span class="smallfont">update info </span><br /> <p> <textarea name="bio" rows=10 cols=90><?php echo $display_block = "$item_bio" ?></textarea></p> <br /> <span class="titles">artists</span><br /> <span class="smallfont">update info</span><br /> <p> <textarea name="other_artists" rows=10 cols=90><?php echo $display_block = "$item_other_artists" ?></textarea></p> <br /> <br /> <input type="submit" name="Submit" value="update"> </form> Here is the "form action file" artist_profile_update.php: ( I would also like to redirect this back to the original page.) <?php mysql_connect("localhost", "", "", "sgallery") or die(mysql_error()); mysql_select_db("sgallery") or die(mysql_error()); $item_bio = mysql_real_escape_string($_POST['bio']);; $item_other_artists = mysql_real_escape_string($_POST['other_artists']); $sql="UPDATE store SET bio='$item_bio', other_artists='$item_other_artists' WHERE username = '".$_SESSION["username"]."'"; if (!mysql_query($sql)) { die('Error: ' . mysql_error()); } ?> Any suggestions?? I'm really stuck on this one. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/206307-trouble-with-updating-table-with-form/ Share on other sites More sharing options...
ejaboneta Posted June 30, 2010 Share Posted June 30, 2010 Looks fine to me.... Are you sure you are connecting to the database ok? Quote Link to comment https://forums.phpfreaks.com/topic/206307-trouble-with-updating-table-with-form/#findComment-1079301 Share on other sites More sharing options...
PFMaBiSmAd Posted June 30, 2010 Share Posted June 30, 2010 The php code you posted does not have a session_start() statement in it (assuming you posted all the code in the file), so it is unlikely that your $_SESSION variable has a value. You could always check what your query actually contains by echoing the $sql variable. Quote Link to comment https://forums.phpfreaks.com/topic/206307-trouble-with-updating-table-with-form/#findComment-1079304 Share on other sites More sharing options...
scmeeker Posted June 30, 2010 Author Share Posted June 30, 2010 I put the session_start() at the beginning of the PHP action page (its already at the top of the form page) and its now updating the table in the database successfully BUT is giving me this warning: Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent Quote Link to comment https://forums.phpfreaks.com/topic/206307-trouble-with-updating-table-with-form/#findComment-1079308 Share on other sites More sharing options...
PFMaBiSmAd Posted June 30, 2010 Share Posted June 30, 2010 If you read the whole error message, it tells you where your code is sending output at that is preventing the header (needed for the session_start()) from working. Quote Link to comment https://forums.phpfreaks.com/topic/206307-trouble-with-updating-table-with-form/#findComment-1079311 Share on other sites More sharing options...
scmeeker Posted June 30, 2010 Author Share Posted June 30, 2010 Sorry, here is the rest of the Warning. I'm rather confused by it. Line 4 is the session_start(). If the first part if referring to line 2, that is <?php. Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at artist_profile_update.php:2) in artist_profile_update.php on line 4 pie Quote Link to comment https://forums.phpfreaks.com/topic/206307-trouble-with-updating-table-with-form/#findComment-1079318 Share on other sites More sharing options...
scmeeker Posted June 30, 2010 Author Share Posted June 30, 2010 Got it! I had to put the <?php session_start();?> by itself before the other PHP coding and it worked fine. Thanks everyone! Quote Link to comment https://forums.phpfreaks.com/topic/206307-trouble-with-updating-table-with-form/#findComment-1079322 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.