SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    Evil Genius MilchstrabeStern's Avatar
    Join Date
    Nov 2003
    Location
    Arizona
    Posts
    1,131
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    $error always returns TRUE

    I am clueless on this one, and I have spent too much time trying to solve the problem - the code always returns a TRUE for $error and $error_assessment_fee, even when the assessment_fee is checked, inserted into the database, and displayed.

    I have checked to make sure the variable is right, and it is. So why does the code return true all the time? This code is at the top of the form document, and the form action is self.

    PHP Code:
    $error FALSE;
    if (isset(
    $_POST['submit1']) or isset($_POST['submit2'])) {
        
            if(!
    is_numeric($_POST['scholarship'])) {
        
            
    $error TRUE;
            
    $error_scholarship "<p class='red'>Please enter a numeric value!</p>";
            } 
            if (empty(
    $_POST['assessment_fee'])) {
            
    $error TRUE;
            
    $error_assessment_fee "<p class='red'><b>The assessment fee is REQURIED!</b></p>";
            } 
            
            
        } 
    ]

  2. #2
    SitePoint Zealot basbd's Avatar
    Join Date
    Oct 2005
    Location
    Oregon, USA
    Posts
    155
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What's your assessment_fee checkbox code look like? What does print_r($_POST); give you when the checkbox is not checked?

  3. #3
    SitePoint Wizard
    Join Date
    Jan 2004
    Location
    3rd rock from the sun
    Posts
    1,005
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    beats me.

    http://www.deformedweb.co.uk/php_variable_tests.php
    Testing for nulls, zero and isset()

    Above link might help.

    I thought error might be a reserved word, but it doesnt seem so, still...

    What happens if you reverse it? declare it true to start with?
    isempty()

  4. #4
    Evil Genius MilchstrabeStern's Avatar
    Join Date
    Nov 2003
    Location
    Arizona
    Posts
    1,131
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Alright, I knew it was a stupid error somplace in my code. By my code had gotten so long, that those things just flew right by me. I should use loops more often when I can or find better ways to clean my code up - maybe make some more functions.

    I fixed the problem -- I had the name of the field incorrect (in the form).

    Thanks!
    ]


Bookmarks

Posting Permissions

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