Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 5 of 5
  1. #1
    Member
    Join Date
    Aug 2004
    Location
    Akron and Alliance, Ohio
    Posts
    41
    Member #
    7231
    Hi,
    I have a part of a script:

    PHP Code:
    //check document extension\\
        
    $file_type substr($_FILES["resume_upload"]["name"], -3);
        echo 
    $file_type;
        
    $doc 'doc';
        
    $pdf 'pdf';
        
    //echo $doc;
        //echo $pdf;
        
    if(($file_type != "doc") || ($file_type != "pdf")){
            
    $resume1 FALSE;
            
    $message .= "**Your uploaded Resume is not in the right format.<br />";
        }
        else{ 
    ...that is supposed to look at an uploaded file, put the last three letters of the file name (the extension) into $file_type and compare it to the words 'doc' and 'pdf' to see if the file is in .doc or .pdf format, like it's supposed to be. I must be missing something because it won't go past the first if even if the $file_type variable prints out pdf. Can someone please help me!?

  2.  

  3. #2
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,715
    Member #
    5580
    Liked
    717 times
    Let's say your file type is "pdf"

    See this line:

    if(($file_type != "doc") || ($file_type != "pdf")){

    You have an OR statement, so it passes the first one "doc",
    but fails the second one "pdf" ... your if statement is
    then FALSE because you're saying:

    if "pdf" is NOT "doc" OR "pdf" is NOT "pdf" then $resume1=FALSE.

    It's the same thing the other way around ...

    So no matter what the file type is, it's always FALSE!

    Try it this way:

    $resume1="FALSE";
    if(($file_type === "doc") || ($file_type === "pdf")){
    $resume1="TRUE";
    }

    It always starts out as false, but if either one is equal to
    the correct file type(s), it makes it true. If it's not either
    of them, it stays false, so you don't even need the else statement.


    .


  4. #3
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Good catch mlseim... I looked at it for a minute and then gave up, hahaha.

  5. #4
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    Sorry to bump this thread, I am looking for something, but in mlseim's post, he has quoted the [probable] boolean variables.

    No quotes needed, unless strings.

  6. #5
    Senior Member Shani's Avatar
    Join Date
    Nov 2004
    Posts
    1,140
    Member #
    8171
    Can't get more obvious...

    The resume is FALSE if it != "doc" AND !="pdf".
    Shani

    I have an eye for detail like you'd never believe.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 09:55 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com