TomTees Posted November 27, 2010 Share Posted November 27, 2010 My application just broke about 2 hours ago and for the life of me I don't know what I did to it?! :'( (I was coding a different file, and when I tried to run the main - unrelated index.php - things stopped working?!) Here is a snippet of the suspect code... if ($rows == 0){ // Email and Username are available. // Add User to the database. $q = "INSERT INTO users(username, email, pass, first_name, last_name, date_expires) VALUES('$u', '$e', '" . get_password_hash($p) . "', '$fn', '$ln', ADDDATE(NOW()), INTERVAL 1 MONTH))"; $r = mysqli_query($dbc, $q); When I step through my code in NetBeans, the INSERT is failing and I don't know why because I haven't touched this code since this morning and it was working all day... Please help! TomTees Quote Link to comment https://forums.phpfreaks.com/topic/219965-insert-failing-in-php-code/ Share on other sites More sharing options...
Alex Posted November 27, 2010 Share Posted November 27, 2010 Looks like you have an extra ) here: ADDDATE(NOW()), INTERVAL 1 MONTH) Shouldn't that be: ADDDATE(NOW(), INTERVAL 1 MONTH) ? Quote Link to comment https://forums.phpfreaks.com/topic/219965-insert-failing-in-php-code/#findComment-1140218 Share on other sites More sharing options...
TomTees Posted November 27, 2010 Author Share Posted November 27, 2010 Looks like you have an extra ) here: ADDDATE(NOW()), INTERVAL 1 MONTH) Shouldn't that be: ADDDATE(NOW(), INTERVAL 1 MONTH) ? Yep, that fixed it! Bizzare-o... I didn't touch that code all evening and when I went to run a different module - the error is in "Registration" and I was working on "Log In" - things broke?! Only thing I can think is that I was toggling between the code I downloaded from my book and maybe my code was broken and I didn't catch it... THANKS!! BTW, what exactly does that code do?? ADDDATE(NOW(), INTERVAL 1 MONTH) I guess it adds one month to the current time-date stamp? TomTees Quote Link to comment https://forums.phpfreaks.com/topic/219965-insert-failing-in-php-code/#findComment-1140220 Share on other sites More sharing options...
revraz Posted November 27, 2010 Share Posted November 27, 2010 Yes http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html Quote Link to comment https://forums.phpfreaks.com/topic/219965-insert-failing-in-php-code/#findComment-1140225 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.