cliftonbazaar Posted April 11, 2009 Share Posted April 11, 2009 I can't seem to get this line of code working - $sql = "UPDATE customers SET member'{$_SESSION['referrer']}'='1' WHERE userName='{$_SESSION['userName']}' "; More specifically it's the SET member'{$_SESSION['referrer']}'='1' that I don't know how to do. My database has memberships for different websites; so the fields are 'memberkoala', 'memberalien', 'memberdragon' e.t.c I always need the work 'member' in there but I also need to add the variable $_SESSION['referrer'] to the filed name. Quote Link to comment Share on other sites More sharing options...
gffg4574fghsDSGDGKJYM Posted April 12, 2009 Share Posted April 12, 2009 I'm not sure exactly what you want but i think you are looking for CONCAT : http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_concat But if you have many website in the same table why you don't add a column like that website varchar(50) AND UPDATE customers SET referer='$_SESSION['referrer']', website='www.something.com' WHERE username='$_SESSION['userName']'; Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted April 12, 2009 Share Posted April 12, 2009 Remove the single-quotes that are around '{$_SESSION['referrer']}' and if the fields are numeric, remove the single-quotes that are around the '1' You can always echo your $sql variable after it has been assigned the query string to see what exactly is in it. Quote Link to comment Share on other sites More sharing options...
cliftonbazaar Posted April 12, 2009 Author Share Posted April 12, 2009 Remove the single-quotes that are around '{$_SESSION['referrer']}' and if the fields are numeric, remove the single-quotes that are around the '1' Brilliant, that did the trick You can always echo your $sql variable after it has been assigned the query string to see what exactly is in it. This is one of things that I would never have thought about but once you read it you think "why the heck didn't I think of that before, it's so simple!" Thanks for the replies. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.