I have a web site that has a user database. Most users have a subscription that expires non a certain date but I also have other users that I want to restrict the number of actual logins. I have a field called “logins” in my tblCustomers as well as a field that designates the type of login. What I am having trouble with is updating the database when the user logs in. The following code is what I have but it doesn’t do anything. I am new to php and use Dreamweaver to create most of my code :D. Can anyone help?
[php]
//Connect to mysql
$cat = $row_rsUser[‘catID’];
$Cust = $row_rsUser[‘CustomerID’];
$Curr = $row_rsUser[‘logins’]+1;
if ($cat==2){
mysql_query(“UPDATE tblCustomers SET logins = ‘$Curr’ WHERE CustomerID =’$Cust’”)
}
[/php]
Your code is missing a semicolon after mysql_query(). Have you checked to see if the query succeeded?
[php]$query = mysql_query(“UPDATE tblCustomers SET logins = ‘$Curr’ WHERE CustomerID =’$Cust’”);
if($query == false) {
echo 'Failed: ', mysql_error();
}[/php]
Also, the speech marks that you have put at the start and end of the query string are not speech marks, but special characters. I don’t know if your editor has put these in or if it happened when you posted this snippet.
You have (different speech mark characters for opening and closing marks):
“ ”
When they should be:
" "
Thanks muchly. problem solved.