willows Posted June 20, 2003 Share Posted June 20, 2003 I have added the following line to the easy populate to convert the price from euro to usd, but I am getting an error. I am not an php guru so can some one have a quick look at the code and see if there is a glaring error. in the file easypopulate I have added. Code: require('includes/application_top.php'); require(DIR_WS_CLASSES . 'currencies.php'); $currencies = new currencies(); .... ... ... $shop_base_currency = "EUR"; .. ... .. case 'froogle':... echo "froogle prices "; echo "<br> Euro Price = $v_products_price"; ---> $v_products_price = $currencies->format($v_products_price, true, $shop_base_currency ,USD); echo "<b> USD Price = $v_products_price </b>"; I am getting the following error on the line with the arrow. froogle prices Euro Price = Fatal error: Call to a member function on a non-object in /usr/hsphere/local/home/mcevoys/mcevoys.ie/admin/easypopulate2.php on line 1165 As far as I can see I am calling the format currency function correctly but there is some thing else I am missing. help is appreciated, thanks for taking the time to read my posting Regards Sean Owens Quote free is often better than cheap Link to comment Share on other sites More sharing options...
mdfst13 Posted June 21, 2003 Share Posted June 21, 2003 Hello, I think that your line 1165 would fit in around line 1070 on my fresh download of EP 2.6. Line 930 on mine is function ep_create_filelayout($dltype){ which starts a function that continues through line 1151. The froogle case is on line 1065. On my line 303, I have the require for application_top.php. I'm guessing that your code works similarly. However, if that is so, then $currencies is being defined outside the function's scope. Unlike C (et.al.), PHP does not automatically allow access to global variables inside of other scopes. Thus, I suspect that it thinks that the $currencies variable that calls the is a *different* variable than ithe one defined by the requires. There are two ways that I can see to fix this: one, move the initial declaration of $currencies into the function, which would be the preferred place to have it if you do not use it in other functions; two, if you are using it in other functions, add a global $currencies; at the beginning of the function. Of course, maybe I'm misreading your code. Let us know what you find out. Thanks, Matt Quote I love deadlines. I like the whooshing sound they make as they fly by. ---Douglas Adams Link to comment Share on other sites More sharing options...
willows Posted June 26, 2003 Author Share Posted June 26, 2003 Hi Matt that solution worked fine, thank you for the time and the help. Regards Sean Owens Quote free is often better than cheap 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.