Jump to content

Updating row details from form input


wiggst3r

Recommended Posts

Hi

 

I have a form, which i want to update a row's details in a mysql database

 

My form is:

 

			echo '<form action="save.php" name="insert_priority" METHOD="post">';
		echo '<table>';
		echo '<input type="hidden" name="briefed"'; {echo "value=\"" . $_POST['catid'] . "\"";}echo ' />';
		echo '<td><input class="briefed" type="text" name="briefed"'; if(isset($_POST['briefed'])){echo "value=\"" . $_POST['briefed'] . "\"";}echo ' /></td>';
		echo '<td><input class="job" type="text" name="job"'; if(isset($_POST['job'])){echo "value=\"" . $_POST['job'] . "\"";}echo ' /></td>';
		echo '<td><input class="category" type="text" name="category"'; if(isset($_POST['category'])){echo "value=\"" . $_POST['category'] . "\"";}echo ' /></td>';
		echo '<td><input class="needed" type="text" name="needed"'; if(isset($_POST['needed'])){echo "value=\"" . $_POST['needed'] . "\"";}echo ' /></td>';
		echo '<td><input class="status" type="text" name="status"'; if(isset($_POST['status'])){echo "value=\"" . $_POST['status'] . "\"";}echo ' /></td>';
		echo '<td class="gap"></td>';
		echo '<td class="gap"></td>';
		echo '<td class="save"><input type="image" style="margin-top: 4px;" src="images/sm-tick-box.jpg" height="20" class="save" alt="Submit ">
</td>';
		echo '</table>';
		echo '</form>';

 

and the code to update the row is:

 

$sql = "UPDATE Categories SET (briefed = '$briefed', job ='$job', category ='$category', needed ='$needed', status ='$status', orderid ='') WHERE catid = $catid )";
mysql_query($query);

 

I get the following errors:

 

string(145) "UPDATE Categories SET (briefed = 'PP', job ='PP', category ='PPPPPPPPPPPPPPPPPPPPPPPP', needed ='PP', status ='PP', orderid ='') WHERE catid = )" Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(briefed = 'PP', job ='PP', category ='PPPPPPPPPPPPPPPPPPPPPPPP', needed ='PP', ' at line 1

 

Do I need to change both the way the form accepts input and my SQL statement to achieve this?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/114250-updating-row-details-from-form-input/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.