wiggst3r Posted July 11, 2008 Share Posted July 11, 2008 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 More sharing options...
rmbarnes82 Posted July 11, 2008 Share Posted July 11, 2008 Hi, You seem to have 2 problems here. First remove all of the brackets from your SQL query, they don't need to be there. Second, the SQL error seems to be caused by the fact that $catid is empty, hence WHERE catid = ) in your SQL error. Robin Link to comment https://forums.phpfreaks.com/topic/114250-updating-row-details-from-form-input/#findComment-587469 Share on other sites More sharing options...
wiggst3r Posted July 11, 2008 Author Share Posted July 11, 2008 Is there any way that I can make it so that when I'm updating a row, it updates it based on it's catid? I thought having a hidden field would maybe help? Link to comment https://forums.phpfreaks.com/topic/114250-updating-row-details-from-form-input/#findComment-587499 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.