Jump to content

INSERT failing in PHP code


TomTees

Recommended Posts

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

 

 

Link to comment
https://forums.phpfreaks.com/topic/219965-insert-failing-in-php-code/
Share on other sites

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

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.