Function problems

    Date: 05/11/07 (PHP Community)    Keywords: no keywords

    Hi all!

    I am having some problems with a function that I have created for myself. I cannot figure out why it is not working because there are two other functions that are coded the exact same way and they work just fine.

    edited to add: If I hard code the case into the function call it works properly. So for whatever reason it isn't getting the correct information from $user while the others are. Can anyone suggest why this would be happening?

    edited again to note that the problem is now resolved. thanks for the help!

    function determineDownloads($a) {
    	switch ($a) {
    		case "canbus":
    			$bronze = 500;
    			$silver = 1000;
    			$gold = 2000;
    			break;
    		case "canman":
    			$bronze = 2000;
    			$silver = 2000;
    			$gold = 2000;
    			break;
    		case "amman":
    			$bronze = 5000;
    			$silver = 5000;
    			$gold = 5000;
    			break;
    		case "namrep":
    			$bronze = 2000;
    			$silver = 2000;
    			$gold = 2000;
    			break;
    	}
    
    	echo "Bronze Package downloads: ".$bronze."  records<*br>\n";
    	echo "Silver Package downloads: ".$silver." records<*br>\n";
    	echo "Gold Package downloads: ".$gold." records\n";
    
    }


    When I call this function (determineDownloads($user)) all it puts out is:

    Bronze Package downloads: records
    Silver Package downloads: records
    Gold Package downloads: records

    without the actual record count. The function below works properly and displays the correct information and I can't find or figure out why it works but the above doesn't. That is, the below function gets the correct value for $user but the above doesn't. The value doesn't change and is retrieved when the page is first loaded. It doesn't make sense that one function would get the correct value and another wouldn't. At least not that I can see. Any help would be greatly appreciated.

    Working function:
    function determineResults($a) {
    	switch ($a) {
    		case "canbus":
    			$bronzeresults = 500;
    			$silverresults = 500;
    			$goldresults = 500;
    			break;
    		default:
    			$bronzeresults = 500;
    			$silverresults = 1000;
    			$goldresults = 2000;
    			break;
    	}
    
    	echo "Bronze Package search results: ".$bronzeresults."<*br>\n";
    	echo "Silver Package search results: ".$silverresults."<*br>\n";
    	echo "Gold Package search results: ".$goldresults."\n";
    }


    (Please ignore the * in the br tags, for whatever reason it was displaying those as line breaks instead of the actual code)

    Source: http://community.livejournal.com/php/565481.html

« Using something other then... || Problem: opendir »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home