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? Link to comment https://forums.phpfreaks.com/topic/78422-solved-do-variables-change-instantly/ 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. Link to comment https://forums.phpfreaks.com/topic/78422-solved-do-variables-change-instantly/#findComment-396843 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 Link to comment https://forums.phpfreaks.com/topic/78422-solved-do-variables-change-instantly/#findComment-396845 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 ? Link to comment https://forums.phpfreaks.com/topic/78422-solved-do-variables-change-instantly/#findComment-396849 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. Link to comment https://forums.phpfreaks.com/topic/78422-solved-do-variables-change-instantly/#findComment-396854 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.