SirChick Posted November 22, 2007 Share Posted November 22, 2007 Hey, quick question ... say i have something like this: Lets say in my database Username = SirChick. $Username = $row['Username']; // from a query Then i put a query to change username later on in the script to be "Test"..... Then i do If($Username == 'Test') after wards... will $Username have changed to Test or will it still remain SirChick because it was assigned before query change? Quote Link to comment Share on other sites More sharing options...
revraz Posted November 22, 2007 Share Posted November 22, 2007 The DB will have the new value. If you don't update $Username then how can it have the new value? You would have to either re-query or update $Username the same time you do the update to the DB. Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted November 22, 2007 Share Posted November 22, 2007 they will not change unless you assign a new value or it goes out of scope the "==" is a comparision operator the "=" is a assignment operator Quote Link to comment Share on other sites More sharing options...
SirChick Posted November 22, 2007 Author Share Posted November 22, 2007 So i would have to do $Username = $row['Username']; // from a query a second time ? Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted November 22, 2007 Share Posted November 22, 2007 That'd be pretty pointless. No need to query the database another time. Just use the same value that you used to update the database to change the value of the variable, $Username. 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.