Frankie T Posted October 27, 2010 Share Posted October 27, 2010 Hey there, Pretty frustrated with this. It seems so simple, but I've been staring at it and toying with it for ages, so I figured I'd post here. I have a variable called "$isTaken" that seems to be losing its value in an essential step in my function. Take a look. function subdomainTaken($inputtedSubdomain) { //Initialize $isTaken to 'true' $isTaken = true; echo "isTaken STARTS AS: <i>" . $isTaken . "</i><br />"; //FOR TESTING PURPOSES ONLY. VARIABLE HAS VALUE HERE //Check subdomain in database $subdomainDBQuery = mysql_query("SELECT * FROM `companies` WHERE company_subdomain = '$inputtedSubdomain'"); $foundResult = mysql_num_rows($subdomainDBQuery); if ($foundResult > 0) { $isTaken = true; } else { $isTaken = false; } return $isTaken; } By the time I get to the if statement, $isTaken has no value. I've echoed it to be sure. Any ideas? Thanks, Frank Link to comment https://forums.phpfreaks.com/topic/216953-variable-seems-to-be-losing-its-data/ Share on other sites More sharing options...
Pikachu2000 Posted October 27, 2010 Share Posted October 27, 2010 Try var_dump()ing it instead of echoing it. Link to comment https://forums.phpfreaks.com/topic/216953-variable-seems-to-be-losing-its-data/#findComment-1126930 Share on other sites More sharing options...
Frankie T Posted October 27, 2010 Author Share Posted October 27, 2010 Ah! Thank you so much! I didn't know about that function. What you told me allowed me to rule out what I thought it was. Turns out, there was just an error in my logic. Thanks again! Link to comment https://forums.phpfreaks.com/topic/216953-variable-seems-to-be-losing-its-data/#findComment-1126934 Share on other sites More sharing options...
Pikachu2000 Posted October 27, 2010 Share Posted October 27, 2010 I thought that would help you figure out what was going on there . . . Link to comment https://forums.phpfreaks.com/topic/216953-variable-seems-to-be-losing-its-data/#findComment-1126936 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.