jigsawsoul Posted January 24, 2010 Share Posted January 24, 2010 I don't get an mysql or php error message. and $apologiesid, $occurrenceid and $staffid are all carry the right information from my testing. but yet it still goes to the else part of the statement. can anyone see why??? $query = "INSERT INTO web_roles (apologies_id) VALUES ('$apologiesid') WHERE occurrence_id = '$occurrenceid' AND staff_id = '$staffid'"; if (mysql_query ($query)) { $_SESSION['message'] = " <div class='notification success png_bg'> <a href='#' class='close'><img src='http://stuweb.cms.gre.ac.uk/~hr728/_web/_resources/images/icons/cross_grey_small.png' title='Close this notification' alt='close' /></a> <div> Your apologies have been sent... </div> </div>"; header('Location: list.php'); } else { $_SESSION['message'] = " <div class='notification error png_bg'> <a href='#' class='close'><img src='http://stuweb.cms.gre.ac.uk/~hr728/_web/_resources/images/icons/cross_grey_small.png' title='Close this notification' alt='close' /></a> <div> Error. please can't admin </div> </div>"; header('Location: list.php'); } [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/189656-cant-you-see-where-im-going-wrong-anyone-help-please/ Share on other sites More sharing options...
jigsawsoul Posted January 24, 2010 Author Share Posted January 24, 2010 $query = "INSERT INTO web_roles (apologies_id) VALUES ('$apologiesid') WHERE occurrence_id = '$occurrenceid' AND staff_id = '$staffid'"; Can anyone see anything wrong with this line of code. ?? Quote Link to comment https://forums.phpfreaks.com/topic/189656-cant-you-see-where-im-going-wrong-anyone-help-please/#findComment-1000936 Share on other sites More sharing options...
wildteen88 Posted January 24, 2010 Share Posted January 24, 2010 No, but to see if your query is failing due to an error use mysql_error. Quote Link to comment https://forums.phpfreaks.com/topic/189656-cant-you-see-where-im-going-wrong-anyone-help-please/#findComment-1000938 Share on other sites More sharing options...
jigsawsoul Posted January 24, 2010 Author Share Posted January 24, 2010 i get this 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 'WHERE occurrence_id = '35' staff_id = '8'' at line 1 any idea where the problem lays.. as i still can't find it. Quote Link to comment https://forums.phpfreaks.com/topic/189656-cant-you-see-where-im-going-wrong-anyone-help-please/#findComment-1000941 Share on other sites More sharing options...
jigsawsoul Posted January 24, 2010 Author Share Posted January 24, 2010 as you guys can see it relates to right data in the web_roles table, in the image [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/189656-cant-you-see-where-im-going-wrong-anyone-help-please/#findComment-1000944 Share on other sites More sharing options...
wildteen88 Posted January 24, 2010 Share Posted January 24, 2010 $query = "INSERT INTO web_roles (apologies_id) VALUES ('$apologiesid') WHERE occurrence_id = '$occurrenceid' AND staff_id = '$staffid'"; Can anyone see anything wrong with this line of code. ?? DOH! I didn't read your query properly. INSERT statements do not have a WHERE clause. Are you inserting a new record or are you wanting to update an existing record? For updating existing records you should use an UPDATE query. Quote Link to comment https://forums.phpfreaks.com/topic/189656-cant-you-see-where-im-going-wrong-anyone-help-please/#findComment-1000945 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.