Page 2 of 2 FirstFirst 12
Results 41 to 46 of 46

Thread: [RESOLVED] PHP Validator/Error checking

  1. #41
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: [RESOLVED] PHP Validator/Error checking

    Post #39 is an example. You need to actually read what I wrote and apply it to your code.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  2. #42

    Thread Starter
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: [RESOLVED] PHP Validator/Error checking

    Quote Originally Posted by visualAd View Post
    Post #39 is an example. You need to actually read what I wrote and apply it to your code.
    Sorry, I have added to my last post!

    Edit:

    It seems that the loop is not being triggered! I manual put the total in for the previous two rows and it works. However for some reason the loop only counts the final row in the table and not the rows before it. This is the code I'm using:

    PHP Code:
         for ($i=0$i $depth$i++)
                {
                    
    $item $cart->get_item($i);
                    
    $deleted $item->deleted;
                    if (!
    $deleted){
                        
    $item_id $item->get_item_id();
                        
    $item_name $item->get_item_name();
                        
    $qty $item->get_qty();
                        
    $price $item->get_price();
                        
    $total_amount 170;
                     
    $total_amount $total_amount +($price*$qty);                    
                        echo
    "<tr><td>$item_name</td><td>$qty </td><td>$price</td></tr>";
                            
                    }        
                } 
    The above code has the "$total_amount" variable set to the total of the first two rows I was using. The unedited code is here.
    Last edited by Nightwalker83; Oct 28th, 2009 at 04:40 AM. Reason: Adding more!
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  3. #43
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: [RESOLVED] PHP Validator/Error checking

    Quote Originally Posted by Nightwalker83 View Post
    I have set it like so:

    PHP Code:
    $totalAmount 0
    $total_amount =  $total_amount +($price*$qty); 
    Although, I still get the above message on the second line, I think it has to do with the second "$total_amount" rather than the first.
    you initialised $totalAmount, but you're referring to $total_amount in the actual code. now, I don't know what else you're talking about here, so I'm going to just assume this will fix your initial problem!

    like visualAd and I have been saying, you should be initialising your integer values as a ZERO. you don't initialise it as an equation. treat it like you would another language, if you must, by explicitly declaring every variable you're using at the top of your script:

    PHP Code:
    <?php
      
    //declarations
      
    $type '';
      
    $whatever 0;
      
    $total_amount 0;

      
    //rest of my code goes here

  4. #44

    Thread Starter
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: [RESOLVED] PHP Validator/Error checking

    Quote Originally Posted by kows View Post
    PHP Code:
    <?php
      
    //declarations
      
    $type '';
      
    $whatever 0;
      
    $total_amount 0;

      
    //rest of my code goes here
    Thanks! That worked Although, I'm a bit confused as to why the same code doesn't work when I put "var" in front of it (see post #38)?

    Edit:

    Reading the php manual var on its own is not a keyword unlike in a language such as Visual Basic.
    Last edited by Nightwalker83; Oct 28th, 2009 at 07:51 PM. Reason: Adding more!
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  5. #45
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: [RESOLVED] PHP Validator/Error checking

    the var keyword is for declaring/initialising variables within a class (although not within a method). however, the var keyword is deprecated in PHP5; you can use the public, private or protected keywords instead. this is all about object oriented programming and I'd assume is over your head at this point.

    if you want to declare a variable outside of a class, you can just assign it a value. this isn't javascript :)

  6. #46

    Thread Starter
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: [RESOLVED] PHP Validator/Error checking

    Quote Originally Posted by kows View Post
    the var keyword is for declaring/initialising variables within a class (although not within a method). however, the var keyword is deprecated in PHP5; you can use the public, private or protected keywords instead. this is all about object oriented programming and I'd assume is over your head at this point.
    Ah ok! That confirms what I read in the "cart.php" link to script posted in post #42. I have done a bit of OOP but I still struggle with stuff sometimes.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width