Jump to content

update multiple fields in mysql


RopeADope

Recommended Posts

I have some php code that's supposed to execute a mysql statement to update an already existing record.  I can't figure out why it doesn't update.  Here's the bit of code.

 

The Form:

echo "<form method=\"post\" action=\"edit2.php\" enctype=\"multipart/form-data\">
<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"100000\">
<input type=\"hidden\" name=\"id\" value\"$id\">
<tr><td>Image</td><td></td><td><img src=\"$dir\" width=\"50\" height=\"50\"></td></tr>
<tr><td>Upload New Image</td><td></td><td><input type=\"file\" name=\"file\" id=\"file\"></td></tr>
<tr><td>Type</td><td></td><td><input type=\"text\" name=\"type\" value=\"$type\"></td></tr>
<tr><td>Name</td><td></td><td><input type=\"text\" name=\"product_name\" value=\"$product_name\"></td></tr>
<tr><td>Price</td><td>\$</td><td><input type=\"text\" name=\"price\" value=\"$price\"></td></tr>
<tr><td>Description</td><td></td><td><input type=\"text\" name=\"description\" value=\"$description\"></td></tr>
<tr><td colspan=\"3\"><center><input type=\"submit\" value=\"Submit\"></td></tr></form>";

 

 

The update:

<?php
include('./inc/session.php');

$id=$_POST['id'];
$type=$_POST['type'];
$product_name=$_POST['product_name'];
$price=$_POST['price'];
$description=$_POST['description'];

include('./inc/connect.php');
$sql="UPDATE products SET type='$type', product_name='$product_name', price='$price', description='$description' WHERE id='$id'";
$result=mysql_query($sql)or die(mysql_error());
mysql_close();
echo "Updated";
?>

Link to comment
Share on other sites

Do you recieve an mysql_error? If so, what error is it. You might also want to consider using mysql_real_escape_string for all values going into the query.

 

I don't get any errors, nothing gets updated though.  I'll check out the mysql_real_escape_string and see if that fixes anything.  In the mean time, any other help would be great.

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.