Jump to content

zoobzen

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Posts posted by zoobzen

  1. Hello,

     

    I have an interesting problem to solve ..

     

    I am setting up a few radio buttons to establish a new or returning user. Using the below code I am getting the buttons to act the way I want them to, however, when no button is selected (I cannot have any "pre-selected" for this app) I get an  "Undefined index: userType" error in addition to my own error message to the user. The "mUserTypes" array is what I am using to load the radio buttons, and my "selected" value is mNeworReturn[user_type].

     

    Thanks for any help offered .. Frank

     

     

     

    $this->mNeworReturn = array('user_type' =>  ' ');

    $this->mUserTypes = array ('New' => 'I am a first time customer, 'Return' => 'I am a returning customer');

     

    if (isset ($_POST['Login']))

      {

          $this->mNeworReturn['user_type'] = $_POST['userType'];

     

            if (empty ($_POST['userType']))

                {

                    $this->mUserTypeError = 1;

                    $this->_mErrors++

                  }

         

              }

     

    If needed to review this problem, the below is the whole constructor of the class .. Thanks

     

     

     

    class CheckoutStep1

    {

      // Public stuff

      public $mErrorMessage;

      public $mLinkToLogin;

      public $mLinkToRegisterCustomer;

      public $mEmail = '';

      public $mNeworReturn;

      public $mUserTypes;

      public $mUserTypeError;

      public $mUserError;

     

     

     

      private $_mErrors = 0;

     

      // Class constructor

      public function __construct()

      {

        if (USE_SSL == 'yes' && getenv('HTTPS') != 'on')

          $this->mLinkToLogin =

            Link::Build(str_replace(VIRTUAL_LOCATION, '', getenv('REQUEST_URI')),

                        'https');

        else

          $this->mLinkToLogin =

            Link::Build(str_replace(VIRTUAL_LOCATION, '', getenv('REQUEST_URI')));

     

       

    $this->mLinkToStep2 = Link::ToRegisterCustomer();

     

     

    $this->mNeworReturn = array('user_type' => '');

    $this->mUserTypes = array ('New' => 'I am a first time customer',

        'Return' => 'I am a returning customer');

     

    if (isset($_POST['Login']))

    {

          $this->mNeworReturn['user_type'] = $_POST['userType'];

     

      if (empty ($_POST['userType']))

          {

            $this->mUserTypeError = 1;

            $this->_mErrors++;

      }

         

    }

     

      }

  2. Something else interesting here, when I run the following code:

     

    $this->mProdCat = Catalog::GetCategoryByProduct($this->_mProductId);

    if (array_key_exists('category_id', $this->mProdCat))

            $this->$mProdSelect =

              (int)$this->mProdCat['category_id'];

          else

            trigger_error('CategoryId not set');

     

    $this->mProdCat  reads back as the term Array in my browser .. when I run the query manually:

     

    SELECT category_id

      FROM product_category

      WHERE product_id = inProductId;

     

    I get the expected result under category_id

     

    Can anyone offer anything?

     

    Thanks ..

     

    Frank

     

  3. I have tried casting the result as an int after this statement (becasue this->mProductSize requires an int) but same result. I am a real noob and I suspect that I may need additional processing since mProdCat is a variable (should only contain one number). I do not need to do anything with mProductSize though and it returns a much larger array.

     

    Any suggestions on how I may "process further"?  I have tried giving mProductSize things like mProdCat[0] and mprodCat['category_id'] to no avail.

     

    Thanks .. Frank

  4. This is the varibale that is giving the problem..

     

    $this->mProdCat = (int)Catalog::GetCategoryByProduct($this->_mProductId);

     

    I am using the return of this as the variable input to the following ..

     

    $this->mProductSize = Catalog::GetProdsByCategory($this->mProdCat);

     

    I have read (and reread) my typing and verified my typing. and I am still only getting as return of the value 1 from    this->ProdCat  I am stumped..

     

    Thanks for the interest ..

     

    Frank

  5. Hello,

     

    I am a real noob here and I am pulling my hair out over this problem ..

     

    I have a variable defined and I am only able to get a 1 or 0 value when calling it .. it is only one line, and interestingly, other just like it are working fine. Here is the line ..

     

    $this->mProdCat = (int)Catalog::GetCategoryByProduct($this->_mProductId);

     

    it is inside a function that is calling to the following ..

     

    // Retrieves category id from product id

      public static function GetCategoryByProduct($productId)

      {

        // Build SQL query

        $sql = 'CALL catalog_get_category_by_product(:product_id)';

     

        // Build the parameters array

        $params = array (':product_id' => $productId);

     

    // Execute the query and return the results

        return DatabaseHandler::GetAll($sql, $params);

      }

     

    Finally, this is how I am using it ..

     

    $this->mProductSize = Catalog::GetProdsByCategory($this->mProdCat);

     

    Everything seems to be doing what it should except since I get this value of 1 (with varified data), I don't populate the list with the proper data .. This is probably easy for the experts, but me .. well ... Thanks for any help offered ..

×
×
  • 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.