Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 15 of 15

Thread: Whats wrong?

  1. #1
    Regular Coder
    Join Date
    May 2005
    Posts
    224
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Whats wrong?

    PHP Code:
    if ($AB == 'On') {
      if (
    $line == 'Front Sideline') {
        
    $yc 204;
      }
      if (
    $line == 'Back Sideline') {
        
    $yc 85;
      }
      if (
    $line == 'Front Hash' || $line == 'Back Hash') {
        
    $yc 206;
      }
      } 
    For some reason, this part of my code is causing me problems.
    I know this, because I tested it over and over and figured out THIS is where the problem is coming from, and nowhere else.

    The problem is this:

    IF:
    $AB is On
    and
    $line is Front Hash or Back Hash

    the script doesnt work

    I'll be glad to add a few more lines above or below, but I'm pretty sure the whole script won't be necessary because I get no errors and everything works fine UNLESS i use the choices stated above.
    Last edited by Crazydog; 08-25-2006 at 07:59 PM.

  • #2
    New Coder
    Join Date
    Oct 2005
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Crazydog
    PHP Code:
    if ($AB == 'On') {

      if (
    $line == 'Front Hash' || $line == 'Back Hash') {
        
    $yc 206;
      }
      } 

    not sure, but try
    PHP Code:
     if (($line == 'Front Hash') || ($line == 'Back Hash')) 

  • #3
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,280
    Thanks
    4
    Thanked 83 Times in 82 Posts

    More descriptive subject

    In the future, please use a more descriptive subject when posting a question. See posting guidelines.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #4
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,174
    Thanks
    19
    Thanked 66 Times in 65 Posts
    have you tried echoing the value of $yc? Saying 'the script doesnt work' isnt very descriptive but it would help you to track down what is causing it not to work - all that snippet does is set the value of a variable.

  • #5
    New Coder
    Join Date
    Aug 2006
    Location
    Netherlands
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Your line is linger then tested literal

    Could it be that $line is longer then the literal you used to test it?
    E.g. run the following snippet and you'll see what I mean.

    PHP Code:
    <?php
    $a 
    'FRONT   ';
    if (
    $a == 'FRONT') echo '1. Is okay ';
    else echo 
    '1. Not okay ';
    if (
    $a == 'FRONT   ') echo '2. Is okay';
    else echo 
    '2. Not okay';
    ?>
    It will echo '1. Not okay 2. Is okay'.

    Ronald
    RTFM is an almost extinct art form, it should be subsidized.

  • #6
    Regular Coder
    Join Date
    Oct 2005
    Posts
    196
    Thanks
    2
    Thanked 0 Times in 0 Posts
    You mentionned this in your original post, but is $AB supposed to equal 'On' or 'ON'?

  • #7
    Regular Coder
    Join Date
    May 2005
    Posts
    224
    Thanks
    1
    Thanked 0 Times in 0 Posts
    @Darth:
    Nope didn't work.

    @Nancy:
    It echoes out correctly.

    @ron:
    "Front Hash" works in other parts of the code, so that's not the problem.

    @Glass:
    It's On.
    On works for Front/Back sideline but not Front/Back hash

  • #8
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    PHP Code:
    <?php
    $line
    ='Front Hash';
    $AB='On';
    if (
    $AB == 'On') {
      if (
    $line == 'Front Sideline') {
        
    $yc 204;
      }
      if (
    $line == 'Back Sideline') {
        
    $yc 85;
      }
      if (
    $line == 'Front Hash' || $line == 'Back Hash') {
        
    $yc 206;
      }
    }
    echo 
    $yc;
    ?>
    results in '206', as it should. The error isn't in this bit of code.

  • #9
    Regular Coder
    Join Date
    May 2005
    Posts
    224
    Thanks
    1
    Thanked 0 Times in 0 Posts
    where else would it be? The only other part with Front/Back hash works fine, unless $AB=On

    I guess I could give someone the script to look at, but I don't want to post it, so if anyone wants it to look at and to help me, send me an email/PM

  • #10
    Regular Coder
    Join Date
    Jul 2004
    Posts
    201
    Thanks
    8
    Thanked 1 Time in 1 Post
    post the file so we can read it.

  • #11
    Regular Coder
    Join Date
    May 2005
    Posts
    224
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Like I said, I wouldn't feel comfortable posting a script I spent ~a week coding....

    I'll be fine if someone PMs/Emails me asking if they can look at it to help, but I don't want it just floating around here.

  • #12
    Regular Coder
    Join Date
    Jul 2004
    Posts
    201
    Thanks
    8
    Thanked 1 Time in 1 Post
    PM it to me then id havea look. cant make any promises though.

  • #13
    Senior Coder
    Join Date
    Aug 2003
    Location
    One step ahead of you.
    Posts
    2,815
    Thanks
    0
    Thanked 3 Times in 3 Posts
    What is "the error"?
    I'm not sure if this was any help, but I hope it didn't make you stupider.

    Experience is something you get just after you really need it.
    PHP Installation Guide Feedback welcome.

  • #14
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Crazydog our issue is you keep insisting there's something wrong with the code you posted, but you are being vague as to what exactly is wrong. When asked what the variable $yc is, you stated it is correct. So... what the heck? Maybe if you could explain the problem? The best you've said is "it's causing me problems", "the script doesn't work", and other generalities that don't give us any clue what the problem actually is.

    EDIT: Yeah what Marek_mar said

  • #15
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,174
    Thanks
    19
    Thanked 66 Times in 65 Posts
    so, let me get this straight, you're perfectly comfortable accepting free help and solutions from experienced professionals; people willing to give up their free time to help you, but you're not comfortable posting your code because it took a week of your precious time?!


  •  

    Posting Permissions

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