Jump to content

Recommended Posts

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]);
      
	}


}
?>

Link to comment
https://forums.phpfreaks.com/topic/143479-solved-cant-figure-out-this-error/
Share on other sites

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.