Edmund Rojas
Edmund Rojas

Reputation: 6606

Postegre sql update statement quotes issue

Im attempting to update a last access time in my database the problem im having is that im using postgres sql and for the strings I must use double quotes inside of single quotes, however this is throwing off the statement, is there a way to get around this

$sql= "UPDATE users SET last_access=' .date("Y-M-D", time ()).' WHERE login_id= '" .$login. "'";
pg_query($conn, $sql);

Upvotes: 0

Views: 99

Answers (1)

Clodoaldo Neto
Clodoaldo Neto

Reputation: 125214

$sql= "UPDATE users SET last_access='"
    .date("Y-m-d", time ()).
    "' WHERE login_id= '$login'";

or easier and cleaner using Postgresql's date:

$sql= "UPDATE users SET last_access = current_date WHERE login_id= '$login'";

Upvotes: 1

Related Questions