Link to home
Start Free TrialLog in
Avatar of sabecs
sabecs

asked on

PHP - need help with Fatal error: Call to undefined function

I have 2 files that are used on a particular page via an include statement.

cart_totals.php contains the following:
function GetCartId()
      {
            // This function will generate an encrypted string and
            // will set it as a cookie using set_cookie. This will
            // also be used as the cookieId field in the cart table
            
            if(isset($_COOKIE["cartId"]))
            {
                  return $_COOKIE["cartId"];
            }
            else
            {
                  // There is no cookie set. We will set the cookie
                  // and return the value of the users session ID
                  
                  setcookie("cartId", session_id(), time() + ((3600 * 24) * 30));
                  return session_id();
            }
      }
.
.
.

cart_functions.php contains the following:
function RemoveItem($PID,$spec) {
            // Uses an SQL delete statement to remove an item from
            // the users cart

            global $conn_data;
            mysql_query("delete from cart where cookieId = '" . GetCartId() . "' and PID = $PID and spec = '$spec'");

      }
.
.
.

I am receiving the following error :
Fatal error: Call to undefined function getcartid() in /home/ourstore/public_html/includes/cart_functions.php on line 46

If I then go and add the function GetCartId() to my cart_functions.php page I receive the following error:
Fatal error: Cannot redeclare getcartid() (previously declared in /home/ourstore/public_html/includes/cart_functions.php:9) in /home/ourstore/public_html/includes/cart_totals.php on line 28

Does anyone know the best way to correct this problem, can I make a function global?
ASKER CERTIFIED SOLUTION
Avatar of Roger Baklund
Roger Baklund
Flag of Norway image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sabecs
sabecs

ASKER

Thanks..