zang8027 Posted February 2, 2009 Share Posted February 2, 2009 Im getting the following error: Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home6/clikndin/public_html/classes/shoppingCart.php on line 4 I cant figure this out. It works fine on localhost/ but as soon as I added it to my web server, i got this. Is the problem with public and private methods and variables? I know its not color coding it on my server and i had to delete "ShoppingCart" in my functions on the other page: Instead of function name_here(ShoppingCart $product_id), I had to put function name_here($product_id). I dont understand why once its uploaded, these things give me errors <?php class ShoppingCart{ private $items = array(); //*********FUNCTION ADDITEM********* public function AddItem($product_id) { if(array_key_exists($product_id, $this->items)) $this->items[$product_id] = $this->items[$product_id] + 1; else $this->items[$product_id] = 1; } //*********FUNCTION GETITEMCOST***************** public function GetItemCost($product_id) { $cost_string = get_item_cost($product_id); $cost_float = "$cost_string" + 0; return $cost_float * $this->GetItemQuantity($product_id); } //*********FUNCTION GETTOTAL********************* public function GetTotal($shipping, $tax) { return $this->GetSubTotal() + $shipping * $tax; } //*********FUNCTION GETSUBTOTAL****************** public function GetSubTotal() { $total=0; foreach($this->items as $product_id => $quantity) $total = $total + $this->GetItemCost($product_id); return $total; } //*********FUNCTION GETITEMS********************* public function GetItems() { return array_keys($this->items); } //*********FUNCTION GETITEMQUANTITY************** public function GetItemQuantity($product_id) { return intval($this->items[$product_id]); } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/143479-solved-cant-figure-out-this-error/ Share on other sites More sharing options...
premiso Posted February 2, 2009 Share Posted February 2, 2009 private $items; To set the initial value set it in the constructor. EDIT: Just read more of the OP. Yea, your server must be using PHP4, it needs upgraded for that code to work as PFMaBiSmAd said. Quote Link to comment https://forums.phpfreaks.com/topic/143479-solved-cant-figure-out-this-error/#findComment-752630 Share on other sites More sharing options...
PFMaBiSmAd Posted February 2, 2009 Share Posted February 2, 2009 Your code is using php5 oop syntax, your on line server is php4. Find out how your host allows you to upgrade to php5 because the end of life of php4 was over one year ago. Quote Link to comment https://forums.phpfreaks.com/topic/143479-solved-cant-figure-out-this-error/#findComment-752636 Share on other sites More sharing options...
zang8027 Posted February 2, 2009 Author Share Posted February 2, 2009 Here is the PHP config page on my server: Hostmonster PHP Configuration If you are not familiar with these options, do NOT change them. This can cause all PHP scripts on your site to stop functioning if misconfigured. NOTES: # If you have custom handlers specified in ~/public_html/.htaccess, changing these settings can overwrite them. If you are not sure, make a backup of ~/public_html/.htaccess before changing settings. PHP5 All files with the extension .php will be handled by the PHP5 engine. Current, most reliable and best performing version of PHP PHP5 (Single php.ini) Same as PHP5, but all subdirectories will use ~/public_html/php.ini PHP5 (FastCGI) All files with the extension .php will be handled by PHP5 FastCGI processes. FastCGI for PHP makes all your PHP applications run through mod_fastcgi instead of mod_suphp. This eliminates the overhead of loading the PHP interpretor on every hit. Since it is always in memory ready for the next hit, the responses will be generated faster. NO MODIFICATIONS to your existing PHP applications will be performed so you can easily enable and disable it at will. PHP5 is selected Quote Link to comment https://forums.phpfreaks.com/topic/143479-solved-cant-figure-out-this-error/#findComment-752645 Share on other sites More sharing options...
PFMaBiSmAd Posted February 2, 2009 Share Posted February 2, 2009 What does a phpinfo(); statement show for the actual runtime value? Quote Link to comment https://forums.phpfreaks.com/topic/143479-solved-cant-figure-out-this-error/#findComment-752657 Share on other sites More sharing options...
zang8027 Posted February 2, 2009 Author Share Posted February 2, 2009 http://www.clikndine.com/test.php Its config file is 4 as u can see.. hmm Quote Link to comment https://forums.phpfreaks.com/topic/143479-solved-cant-figure-out-this-error/#findComment-752663 Share on other sites More sharing options...
zang8027 Posted February 2, 2009 Author Share Posted February 2, 2009 hmm fixed it. i went to PHP config again and just hit save changes and now it works.. must of needed a refresh. thanks! Quote Link to comment https://forums.phpfreaks.com/topic/143479-solved-cant-figure-out-this-error/#findComment-752667 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.