Jerry:
Just so you know where you're going wrong, look at the highlighted line:
[color=green]$query = "INSERT INTO `users_cookie_bin` (`theme`, `username`) VALUES ('$theme', '$usrname') ON DUPLICATE KEY UPDATE SET `theme` = '$theme'";[/color]
[color=red]$query = mysql_query($sql);[/color]
[color=orange]if ( !mysql_query( $query ) ) {[/color]
echo "There was an error, please try again.";
echo mysql_error( );
}
You first define $query as the query string to be executed (good 🙂 ).
Then you run an empty query ($sql) and save that output to the variable $query, overwriting the SQL statements that were previously there.
Then you use the $query variable again as the SQL part of the mysql_query() call, (which at this point $query is false since the red area returned false for no query), which errors out since false is an empty query.
If you remove the red line in the code above, you should see something other than an error message (or something other than the same error message).
Username should be just a unique key, not necessarily a primary index.
Hope that explanation helps some.
@: Why would we need to fetch the rows if we're INSERTing or UPDATEing a row? Just thought I'd mention that.