Note that there are some explanatory texts on larger screens.

plurals
  1. PODisplay the date of creation of a row in mysql
    text
    copied!<p>I added a new row to my users' table to show the date of creation of each user. I tried both timestamp and datetime types for that but it still displays me 0000-00-00 00:00:00 next to each user.</p> <p>here's my code for adding the rows to the users's table </p> <pre><code>$first_name = trim($_REQUEST['first_name']); $last_name = trim($_REQUEST['last_name']); $username = trim($_REQUEST['username']); $password = trim($_REQUEST['password']); $email = trim($_REQUEST['email']); $created = strftime("%Y-%m-%d %H:%M:%S", time()); $insert_sql = sprintf("INSERT INTO users (first_name, last_name, username, password, email, created)" . "VALUES('%s', '%s', '%s', '%s', '%s', '%s');", mysql_real_escape_string($first_name), mysql_real_escape_string($last_name), mysql_real_escape_string($username), mysql_real_escape_string(crypt($password, $username)), mysql_real_escape_string($email), mysql_real_escape_string($created)); mysql_query($insert_sql) or die(mysql_error()); </code></pre> <p>And here's the code that displays the informations</p> <pre><code>$select_users = "SELECT * FROM users"; $result = mysql_query($select_users); while ($user = mysql_fetch_array($result)) { $user_row = sprintf( "&lt;td&gt;&lt;input type='checkbox' name='checkbox[]' id='checkbox[]' value='%d'/&gt;&lt;/td&gt;" . "&lt;td&gt;%s %s&lt;/td&gt; " . "&lt;td&gt;%s&lt;/td&gt;" . "&lt;td&gt;&lt;a href='mailto:%s'&gt;%s&lt;/a&gt;&lt;/td&gt; " . "&lt;td&gt;%s&lt;/td&gt;" . "&lt;td&gt;&lt;a href='javascript:delete_user(%d);'&gt;&lt;img class='delete_user' src='images/trash.png' alt='' title='' border='0' /&gt;&lt;/a&gt;&lt;/td&gt;", $user['user_id'], $user['first_name'], $user['last_name'], $user[username], $user['email'], $user['email'], $user['created'], $user['user_id']); echo $user_row; </code></pre> <p>I got all the fields displayed correctly except for the creation date which shows 0000-00-00 00:00:00 . I don't know what I did wrong. Thank you for the help.</p> <p>EDIT : I already have a field called "updated" which uses "Current_timestamp".</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload