Jump to content

Trouble with Updating table with form


scmeeker

Recommended Posts

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!

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

 

 

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.