I've got a "Parse error: syntax error, unexpected T_VARIABLE in C:\wamp\www\php\vali"

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mandyrjs
    New Member
    • Jun 2010
    • 3

    I've got a "Parse error: syntax error, unexpected T_VARIABLE in C:\wamp\www\php\vali"

    hi im new to php and i want to code a admin login page where i want to match the values from the login form with the values of the database table.....when i run the login page after entering the user name and the password i've got a Parse error: syntax error, unexpected T_VARIABLE in C:\wamp\www\php \validate.php on line 16. Can anybody please help me to slove this matter.

    validate.php
    Code:
    <?php 
    session_start();
    $username= $_POST['adminusername'];
    $password= $_POST['adminpass'];
    	
    $conn= mysql_connect('localhost','root','');
    mysql_select_db('onlinestore',$conn);
    
    $query='SELECT * FROM admin WHERE adminusername='$username' and adminpassword='$password'';
    $result=mysql_query($query);
    if(mysql_num_rows($result)==1)
    {
    header("location:menu.php");
    exit();
    }
    header("location:adminlogin.php");
    exit();
    ?>
    </body>
    Last edited by Dormilich; Jun 3 '10, 04:09 AM. Reason: Please use [code] tags when posting code
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    wrap your query in double quotes. single quoted strings are not parsed and in your case cause the error.

    Comment

    • Mandyrjs
      New Member
      • Jun 2010
      • 3

      #3
      Hey thanks but when i wrap it with double quotes it should go to the menu.php when giving correct username & password right???? but it act as an incorrect input........ca n u help me???

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        what does the corrected code look like?

        Comment

        • Mandyrjs
          New Member
          • Jun 2010
          • 3

          #5
          Code:
          <?php 
          
          $username= $_POST['adminusername'];
          $password= $_POST['adminpass'];
          	
          $conn= mysql_connect('localhost','root','');
          mysql_select_db('onlinestore',$conn);
          
          $query="SELECT * FROM `admin` WHERE adminusername='$username' and adminpassword='$adminpass';
          $result=mysql_query($query);
          if(mysql_num_rows($result)==1)
          {
          header("location:menu.php");
          exit();
          }
          header("location:adminlogin.php");
          exit();
          ?>
          now it says "Parse error: syntax error, unexpected T_STRING in C:\wamp\www\php \validate.php on line 20"
          which is ,header("locati on:menu.php");
          Last edited by Niheel; Jun 3 '10, 06:36 AM. Reason: please use code tags when you post code

          Comment

          • Dormilich
            Recognized Expert Expert
            • Aug 2008
            • 8694

            #6
            if you open a string, you should also close it (i.e. missing closing string delimiter).

            Comment

            Working...