I can see two things that are not correct in the statement:

First, the date you're setting is in UNIX format--but MySQL wont' like
that. You need to use FROM_UNIXTIME.

Second, the username is a string (I guess), but it's not within
quotation marks.

$myquery = "UPDATE penpals SET lastaccess=FROM_UNIXTIME($lastaccessdate)
WHERE ID='$myuserid'";

Two notes:

The MySQL extension does not normally print out errors. You need to
explicity call mysql_error() to do that. In this case, you can add it
after the call to mysql_query(), e.g.:

die (mysql_error());

Also, you are passing HTTP data directly to MySQL. This can allow a
malicious user to insert potentially "evil" code in your call and cause
all sorts of damage. I suggest you consider filtering that information
using one of the many methods available.


Marco


-- 
------------
php|architect - The magazine for PHP Professionals
The first monthly worldwide magazine dedicated to PHP programmers

Come visit us at http://www.phparch.com!
--- Begin Message ---
Can anyone tell me what's wrong with theis code. I don't get any errors but
the databse is never updated:

<?php
  $hostname_connPENPALS = "localhost";
  $database_connPENPALS = "phpenpals";
  $username_connPENPALS = "username";
  $password_connPENPALS = "password";

  $connPENPALS = mysql_pconnect($hostname_connPENPALS,
$username_connPENPALS, $password_connPENPALS) or die(mysql_error());
  $lastaccessdate = gmdate("M d, Y");
  $myuserid = $HTTP_SESSION_VARS['svUserID'];
  mysql_select_db($database_connPENPALS, $connPENPALS);
  $myquery = "UPDATE penpals SET lastaccess=$lastaccessdate WHERE
ID=$myuserid";
  $result = mysql_query($myquery, $connPENPALS);
  header("Location: successfullogin.php");
?>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--- End Message ---
-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to