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
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

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.