Page 1 of 1

[SOLVED] trial time offer

Posted: Sat Sep 10, 2005 10:33 am
by dru_nasty
Hi, I'm new to php/mysql and can't quite figure out why the following script isn't working. It echoes properly but doesn't change the users acces_type_id in the database. The basic plan is when someone registers on the site, I stamp the time() that they registered and store it in the table registered_mem along with all their other user info. Then from that point of registration they have all access to our registered members section of the site. This is allowed with an access_type_id of 14. Then after one weeks time (actually in the below code i have it set for 3 minutes for testing purposes), when they try to access things again, they are changed from a 14 to a 1 for their access_type_id.
The echoe works as I said, but when I check the db the access_type_id is still 14. I have no idea whats going wrong.
Thanks in advance.

Code: Select all

<?
include_once('/usr/home/fss/websites/fivestarsports.net/inc/func.inc.php');
$username = $HTTP_COOKIE_VARS['log']['username'];
$db_conn = five_connect_db();
mysql_select_db('fivestar',$db_conn);
$sql = "SELECT * FROM `registered_mem` WHERE `username`='$username'";
$result = mysql_query($sql, $db_conn) or die(mysql_error());
$row = mysql_fetch_assoc($result);
if($row['access_type_id'] == 14){
	if(($row['date_added']+=(60*3)) <= time()){
		mysql_query("UPDATE `registered_mem` SET(`access_type_id`='1') WHERE `username`='$username'",$db_conn);
		echo "Your access is now 1";
	}
}?>

Posted: Sat Sep 10, 2005 10:38 am
by feyd
are you absolutely sure your query is syntacticly correct? try this change

Code: Select all

mysql_query("UPDATE `registered_mem` SET(`access_type_id`='1') WHERE `username`='$username'",$db_conn) or die(mysql_error());

Posted: Sat Sep 10, 2005 10:48 am
by dru_nasty
I changed that line, and now i get this error:


You have an error in your SQL syntax near '(`access_type_id`='1') WHERE `username`='amanda'' at line 1

Posted: Sat Sep 10, 2005 10:49 am
by feyd
remove the parens. :)

Posted: Sat Sep 10, 2005 10:52 am
by dru_nasty
around what exactly? :?

Posted: Sat Sep 10, 2005 10:57 am
by feyd
where it says the error is :P

Posted: Sat Sep 10, 2005 11:01 am
by dru_nasty
I'm sorry, I don't know what should go and what should stay in this line;

Code: Select all

mysql_query("UPDATE `registered_mem` SET(`access_type_id`='1') WHERE `username`='$username'",$db_conn) or die(mysql_error());

Posted: Sat Sep 10, 2005 11:04 am
by feyd

Code: Select all

mysql_query("UPDATE `registered_mem` SET `access_type_id`='1' WHERE `username`='$username'",$db_conn) or die(mysql_error());

Posted: Sat Sep 10, 2005 11:12 am
by dru_nasty
Ahh, I was thinking of quotes, not parens, sorry.
That did the trick! You made my day, thank you so much! :D