Jump to content

Recommended Posts

Sorry but this is from a post on here, i checked the staement now() out on google to see if the format on the insert is correct but came up with nothink from google is the insert allowed the now() in it and if so what it does.

I understand it in a select but not in a insert please advise me cheers.


Example of the insert i saw in the code cheers.

$sql = mysql_query("INSERT INTO users (first_name, last_name, email, username, password, encryptpass, bio, signup_date) VALUES('$first_name','$last_name','$email','$username','$db_password','$info2', now(),'$random_password')") or die (mysql_error());

this is how i would do it am i correct and is the above another way or wrong cheers.

$signup_date($_POST(['signup_date']));
$signup_date=date("d:m:y");

$sql = mysql_query("INSERT INTO users (first_name, last_name, email, username, password, encryptpass, bio, signup_date) VALUES('$first_name','$last_name','$email','$username','$db_password','$info2','$signup_date','$random_password')") or die (mysql_error());
Link to comment
https://forums.phpfreaks.com/topic/13432-using-the-insert-with-now/
Share on other sites

first off, i'm assuming that [b]now()[/b] is meant for your signup_date?  well you have listed in your first (..) signup_date as your last column, but in your values, $random_password is your last variable. The order of the values must match the order of the columns. 

does this look better cheers thanks.

$signup_date($_POST(['signup_date']));
$signup_date=NOW();

$sql = mysql_query("INSERT INTO users (first_name, last_name, email, username, password, encryptpass, bio, signup_date,random_password') VALUES('$first_name','$last_name','$email','$username','$db_password','$info2','$signup_date','$random_password')") or die (mysql_error());
now() is a sql function, not a php function.

[code=php:0]
$sql = mysql_query("INSERT INTO users (first_name, last_name, email, username, password, encryptpass, bio, signup_date,random_password') VALUES('$first_name','$last_name','$email','$username','$db_password','$info2',now(),'$random_password')") or die (mysql_error());
[/code]

make sure that the signup_date column is type [i]datetime[/i] or varchar(20) or something that can hold 0000-00-00 00:00:00 format.

also you are specifying 9 columns but only have 8 values you are inserting. you seem to have password and encryptpass as columns but only one password type variable.
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.