greens85 Posted July 20, 2009 Share Posted July 20, 2009 Hi all, Im trying to produce an edit form on my website. I have the following code: $sql="UPDATE edworld_jobs SET (contactname, emailaddress, telephone, jobref, jobtitle, startdate, deadline, category, jobdescription, location, hours, contract, salary) VALUES ('$_POST[contactname]','$_POST[emailaddress]','$_POST[telephone]','$_POST[jobref]','$_POST[jobtitle]','$_POST[startdate]','$_POST[deadline]','$_POST[category]','$_POST[jobdescription]','$_POST[location]','$_POST[hours]','$_POST[contract]','$_POST[salary]') WHERE JobID=$job_id"; However it doesnt seem to want to update the appropriate row... can anyone tell me what im doing wrong? thanks Link to comment https://forums.phpfreaks.com/topic/166673-update-query/ Share on other sites More sharing options...
gijew Posted July 20, 2009 Share Posted July 20, 2009 change it to look like this (not doing the entire query) <?php $sql = " UPDATE edworld_jobs SET ( contactname = $_POST['contact_name'], emailaddress = $_POST['emailaddress'], etc = $_POST['etc...'] WHERE id = $id "; ?> Link to comment https://forums.phpfreaks.com/topic/166673-update-query/#findComment-878859 Share on other sites More sharing options...
greens85 Posted July 20, 2009 Author Share Posted July 20, 2009 change it to look like this (not doing the entire query) <?php $sql = " UPDATE edworld_jobs SET ( contactname = $_POST['contact_name'], emailaddress = $_POST['emailaddress'], etc = $_POST['etc...'] WHERE id = $id "; ?> How does make it work? the id field in my database is called JobID so should this not be in the code anywhere? Link to comment https://forums.phpfreaks.com/topic/166673-update-query/#findComment-878869 Share on other sites More sharing options...
gijew Posted July 20, 2009 Share Posted July 20, 2009 It's pseudo code. Replace id with your field names / values. Replace `id = id` WITH `JobID=$job_id` Link to comment https://forums.phpfreaks.com/topic/166673-update-query/#findComment-878909 Share on other sites More sharing options...
greens85 Posted July 20, 2009 Author Share Posted July 20, 2009 Ah right, sorry about that... newish to PHP so still learning. Thanks for your help! Link to comment https://forums.phpfreaks.com/topic/166673-update-query/#findComment-878911 Share on other sites More sharing options...
greens85 Posted July 21, 2009 Author Share Posted July 21, 2009 Hi tried that and got the following error: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /path/to/file/confirmvacancyedit.php on line 15 The code is: if(isset($_GET['id']) && is_numeric($_GET['id'])) { $job_id = (int) $_GET['id']; } $sql = "UPDATE edworld_jobs SET ( contactname = $_POST['contactname'], //THIS IS LINE 15 emailaddress = $_POST['emailaddress'], telephone = $_POST['telephone'], jobref = $_POST['jobref'], jobtitle = $_POST['jobtitle'], startdate = $_POST['startdate'], deadline = $_POST['deadline'], category = $POST['category'], jobdescription = $_POST['jobdescription'], location = $_POST['location'], hours = $_POST['hours'], contract = $_POST['contract'], salary = $_POST['salary'] WHERE JobID=$job_id"; ?> Any ideas why this error is occuring? thanks Link to comment https://forums.phpfreaks.com/topic/166673-update-query/#findComment-879335 Share on other sites More sharing options...
jayjay960 Posted July 21, 2009 Share Posted July 21, 2009 You need quotation marks: <?php if(isset($_GET['id']) && is_numeric($_GET['id'])) { $job_id = (int) $_GET['id']; } $sql = "UPDATE edworld_jobs SET ( contactname = \"$_POST['contactname']\", //THIS IS LINE 15 emailaddress = \"$_POST['emailaddress']\", telephone = \"$_POST['telephone']\", jobref = \"$_POST['jobref']\", jobtitle = \"$_POST['jobtitle']\", startdate = \"$_POST['startdate']\", deadline = \"$_POST['deadline']\", category = \"$POST['category']\", jobdescription = \"$_POST['jobdescription']\", location = \"$_POST['location']\", hours = \"$_POST['hours']\", contract = \"$_POST['contract']\", salary = \"$_POST['salary']\" WHERE JobID = $job_id"; ?> Link to comment https://forums.phpfreaks.com/topic/166673-update-query/#findComment-879337 Share on other sites More sharing options...
greens85 Posted July 21, 2009 Author Share Posted July 21, 2009 You need quotation marks: <?php if(isset($_GET['id']) && is_numeric($_GET['id'])) { $job_id = (int) $_GET['id']; } $sql = "UPDATE edworld_jobs SET ( contactname = \"$_POST['contactname']\", //THIS IS LINE 15 emailaddress = \"$_POST['emailaddress']\", telephone = \"$_POST['telephone']\", jobref = \"$_POST['jobref']\", jobtitle = \"$_POST['jobtitle']\", startdate = \"$_POST['startdate']\", deadline = \"$_POST['deadline']\", category = \"$POST['category']\", jobdescription = \"$_POST['jobdescription']\", location = \"$_POST['location']\", hours = \"$_POST['hours']\", contract = \"$_POST['contract']\", salary = \"$_POST['salary']\" WHERE JobID = $job_id"; ?> Still getting the same error Link to comment https://forums.phpfreaks.com/topic/166673-update-query/#findComment-879343 Share on other sites More sharing options...
greens85 Posted July 21, 2009 Author Share Posted July 21, 2009 Anyone? Really stuck on this.... searched the net loadsa times but cant find out whats wrong with it Link to comment https://forums.phpfreaks.com/topic/166673-update-query/#findComment-879412 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.