EmperorDoom Posted August 8, 2006 Share Posted August 8, 2006 Hey all, I'm using PHP 5.something and I've dealt with many debugging issues by myself before, but this problem I just don't see the solution. Hopefully you can help. I'm trying to write a variable to a new row in a mysql table only if that variable doesn't already exist. (pretty simplistic) I've written the part that checks an array returned from the table to see if the variable exists, this part works fine :)Now I have an else statement that looks like thiselse {$doquery = "INSERT into $table(date,Per1,Per2,Per3,Per4,Per5,Per6,Per7,Per8) VALUES($wheredate,0,0,0,0,0,0,0,0)";$result=mysql_query($doquery) or die("INSERT FAILED");$updatequery = "UPDATE $table SET Per1=1 WHERE date=$wheredate";$result = mysql_query($updatequery) or die("UPDATE FAILED");$centre .= $periodone[$i]." is not in the array with ".$wheredate."|| ";}$periodone is an array with different dates (format yyyy-mm-dd)$wheredate is the current date the program is working with it is set to $year."-".$month."-".$periodone[$i]BTW I know I could do the whole INSERT and UPDATE in one query but i broke it up on purpose.The weird thing is: the output ($centre) displays 24 is not in the array with 2006-08-24 so i know the variable $wheredate is correct but when I check the DB the value in the date field is: "1974" without quotes. where the heck is this number coming from? and what's wrong with my script? Thanks for any input on this.*EDIT*Umm.. i just checked it using a different date, the 11 of august and the value in the date field was 1987 which leads me to believe that the $wheredate is somehow subtracting 08 and 11 from 2006 but why? it's a string right? Quote Link to comment Share on other sites More sharing options...
fenway Posted August 9, 2006 Share Posted August 9, 2006 You need to quote the date string -- otherwise, you get math. Quote Link to comment Share on other sites More sharing options...
EmperorDoom Posted August 9, 2006 Author Share Posted August 9, 2006 Thanks! that worked. I now have a second question which is actually more PHP than mysql but any idea how to get an array of checkboxes from a form that were unchecked? not just left unchecked but actually have the check removed before the form submitted? Quote Link to comment Share on other sites More sharing options...
fenway Posted August 9, 2006 Share Posted August 9, 2006 I'm not familiar with PHP at all, but the logic would require comparing the submitted value to the previously stored value. Quote Link to comment 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.