www.webdeveloper.com
Results 1 to 5 of 5

Thread: How to define variable value as logical value?Simple question, help please

  1. #1
    Join Date
    Sep 2005
    Posts
    1,630

    How to define variable value as logical value?Simple question, help please

    I have in one file of PHP
    variable like:
    PHP Code:
     $validation='true'
    and included in this file another. I would like that IF script will be performed
    and put IF like:
    PHP Code:
     if ( $validation='true')
          {
    $errorinput="This <b>Username or Password</b> is not valid!<br />"; }
         else  {
    $errorinput=""; }
         } 
    Do you know if logical operator works like this or only like function?

  2. #2
    Join Date
    Sep 2005
    Posts
    48
    PHP Code:
    if($validation == 'true'
    You've also got problems with your parens.

    You should follow this format:

    PHP Code:
    if(condition) {
          
    statement;
    } else {
        
    statement;

    or:

    PHP Code:
    if(condition
    {
          
    statement;
    } else 
    {
        
    statement;

    The way you have it now, you have an extra }
    Last edited by LimpBagel; 09-29-2005 at 02:54 PM.

  3. #3
    Join Date
    Sep 2005
    Posts
    1,630
    I would like to give variable $errorinput="" value empty in ELSE script . How is correct? Now is $errorinput="";
    PHP Code:
      if ($validation=='true')
          {
    $errorinput="This <b>Username or Password</b> is not valid!<br />"; }
         else  {
    $errorinput=""; }
         } 

  4. #4
    Join Date
    Jan 2005
    Location
    Alicante (Spain)
    Posts
    7,739
    Toplisek, you keep making the same mistake. If you change your order it might help you to remember.
    to set a variable to a value use =
    $var = TRUE;
    to check a variable is true use ==
    TRUE == $var

    Maybe changing the order will help you think about what you are doing.

  5. #5
    Join Date
    Sep 2005
    Posts
    1,630
    Sorry. I will not make mistake anymore.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles