I'm slowly learning php, and I have had a lot of help from this forum so far. Thanks! Anyway I have code below that edits a record. I had a 2 day nightmare with syntax errors on my last project, that i'm frazzled to start changing this code. Basically I want the code to check the table for a record for the username, and if there is no record then add the record, else if it finds the record to edit it. <?php extract($_POST); extract($_GET); $april_fools = $_POST['april_fools']; $boss_day = $_POST['boss_day']; $boxing_day = $_POST['boxing_day']; $canada_day = $_POST['canada_day']; $chinese_new_year = $_POST['chinese_new_year']; $christmas = $_POST['christmas']; $query = "UPDATE holiday_reminders SET april_fools='".$april_fools."',boss_day='".$boss_day."',boxing_day='".$boxing_day."',canada_day='".$canada_day."',chinese_new_year='".$chinese_new_year."',christmas='".$christmas."' WHERE usrname='$my->username'"; mysql_query($query); Header("Location: my-reminders.php"); exit; ?> Code (markup):
Here a quick example. $query = "UPDATE holiday_reminders SET april_fools='".$april_fools."',boss_day='".$boss_day."',boxing_day='".$boxing_day."',canada_day='".$canada_day."',chinese_new_year='".$chinese_new_year."',christmas='".$christmas."' WHERE usrname='$my->username'"; mysql_query($query); if (!mysql_affected_rows()) { $query = "INSERT INTO table (fields) VALUES (values)"; mysql_query($query) OR die( mysql_error() ); } PHP:
I'm close, but this error gives me no information. The new code is below. 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 ',,,,1)' at line 1 (this error is given when I select to add the christmas (last) option) $query = "UPDATE holiday_reminders SET april_fools='".$april_fools."',boss_day='".$boss_day."',boxing_day='".$boxing_day."',canada_day='".$canada_day."',chinese_new_year='".$chinese_new_year."',christmas='".$christmas."' WHERE usrname='$my->username'";mysql_query($query); if (!mysql_affected_rows()){ $query = "INSERT INTO holiday_reminders (usrname,april_fools,boss_day,boxing_day,canada_day,chinese_new_year,christmas) VALUES ($my->username,$april_fools,$boss_day,$boxing_day,$canada_day,$chinese_new_year,$christmas)"; mysql_query($query) OR die( mysql_error() );} Code (markup):
hmm, I thought maybe because the database fields had a "Not Null" attribute to it, and I wasn't passing something in every field, that was the issue. Nope...
forget it, I think I found it. The error is coming from somewhere else. I won't have a chance to look at it until Moday now anyway. Thanks for all the help!