
gkornbluth
Veteran
Dec 18, 2011, 7:15 AM
Post #1 of 5
(905 views)
Shortcut
|
|
MySQL Syntax Issue when updating expiresDate
|
Can't Post
|
|
I’ve been using the following to add one year to a member’s account expiration date.
// UPDATE ONE YEAR FROM NOW mysql_query("UPDATE `{$TABLE_PREFIX}accounts` SET expiresDate = NOW() + INTERVAL 1 YEAR WHERE password = '" . $_REQUEST['password'] . "' AND username = '" . $_REQUEST['username'] . "'") or die("MySQL Error:<br/>\n". htmlspecialchars(mysql_error()) . "\n"); $userNum = mysql_insert_id(); I’d really rather add the year to their existing expiration date. When I use the code below I get the error:
Notice: Undefined index: expiresDate in /hsphere/local/home/apbcweb/artistsofpalmbeachcounty.org/renewal_thanks.php on line 41 MySQL Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE password = .... etc. // UPDATE ONE YEAR FROM EXISTING EXPIRATION DATE mysql_query("UPDATE `{$TABLE_PREFIX}accounts` SET expiresDate = '".mysql_escape( $_REQUEST['expiresDate'] + 'INTERVAL 1 YEAR' )."', WHERE password = '" . $_REQUEST['password'] . "' AND username = '" . $_REQUEST['username'] . "'") or die("MySQL Error:<br/>\n". htmlspecialchars(mysql_error()) . "\n"); $userNum = mysql_insert_id(); Aside from any actual syntax issues, I think I this is occurring because there is no one logged in when the form is submitted, but I don’t quite know how to resolve the issue. The member is asked for their username and password in order to accomplish the update. I’ve attached the complete file and hope someone has a solution. Thanks, Jerry Kornbluth
|