Results 1 to 3 of 3
  1. #1
    Junior Member Array
    Join Date
    Jul 2011
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    simple php error

    hi all,
    i am getting error on the following php program.it is displaying the error as "Parse error: syntax error, unexpected T_STRING in C:\xampp\htdocs\newlogin.php on line 12"
    not getting what is the problem with it..
    below is my login.php code...
    PHP Code:
    <?php
    if(isset($_POST['sub']))
    {
    mysql_connect("localhost","root","");
    mysql_select_db("test");
    $uname=$_POST['txtuname'];
    $pwd=$_POST['txtpwd'];
    $sqlstt="select * from users where uid='$uname' and pwd='$pwd';
    $data=mysql_query($sqlstt);
    if(mysql_num_rows(
    $data)==1)
    {
    header("
    Location:welcome.php?un=$uname");
    }
    else
    {
    echo "
    invalid";
    }
    }
    ?>
    <form method="
    post" action="">
    username:<input type='text' name='txtuser'>
    <br>
    password:<input type='text' name='txtpwd'>
    <br>
    <input type='submit' name='sub' value='login'>
    </form>
    also is the welcome.php
    PHP Code:
    <?php
    $user
    =$_REQUEST['un'];
    echo 
    "welcome to ".$user;
    ?>
    Last edited by Jordan; 08-12-2011 at 07:39 AM. Reason: Changed code to php tags

  2. #2
    WTF Legend Array
    Join Date
    Jan 2010
    Posts
    4,901
    Thanks
    236
    Thanked 235 Times in 155 Posts


    You don't have the ending double quote " on this line:

    PHP Code:
    $sqlstt="select * from users where uid='$uname' and pwd='$pwd'; 
    It should be:

    PHP Code:
    $sqlstt="select * from users where uid='$uname' and pwd='$pwd'"

  3. #3
    WTF Legend Array
    Join Date
    Nov 2009
    Location
    Estonia
    Posts
    981
    Thanks
    28
    Thanked 79 Times in 59 Posts


    Don't use a variable between " and " use it like this:

    PHP Code:
    $sql 'SELECT something FROM somewhere WHERE something="'.$something.'"'
    Because sometime it won't display your variable's value


 

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
  •