**Parse error: syntax error, unexpected T_VARIABLE in this line "$validate_user_information = sqlsrv_query "select * from userinfo where badgenumber = '"$user_ssn"'";"

//Login Page Starts here
    elseif($_POST["page"] == "users_login") 
    {
        $user_ssn = trim(strip_tags($_POST['badgenumber']));

        $validate_user_information = sqlsrv_query "select * from `userinfo` where `badgenumber` = '"$user_ssn"'";

        if(sqlsrv_num_rows($validate_user_information) == 1)
        {
            $get_user_information = sqlsrv_fetch_array($validate_user_information);
            $_SESSION["VALID_USER_ID"] = $user_ssn;
            echo 'login_process_completed_successfully=yes';
        }
        else
        {
            echo '<br><div class="info">Sorry, you have provided incorrect information. Please enter correct user information to proceed or contact your College Web Administrator. Thank You</div><br>';
        }
    }
    //Login Page Ends here

That syntax doesn't look right. At the very least there should be () around the string and, if memory serves, sqlsrv_query takes more parameters than that... but I could be wrong (too lazy to look up the docs)

can you give a a sample code for log in using php and mssql database??

Hi Jay

I've implemented both native and open source drivers in mssql in Cross Database Engine, you should give it a spin, save you hours of time figuring out what to do. All the connection strings are the same.

http://sourceforge.net/projects/cdeengine/

I would have a look at your SQL, no need to use the escape tags for your table names, you are missing concatenation also.

$sql = "select * from userinfo where badgenumber = '{$user_ssn}'";
$stmt = sqlsrv_query( $conn, $sql);
$arr = sqlsrv_fetch_array ( $stmt);

//inside the $arr are your values you need 

Cross database engine is simpler to use and you don't need to remember whether the connection param comes first or last.

$sql = "select * from userinfo where badgenumber = '{$user_ssn}'";
$obj = $CDE->get_value (0,  $sql); //object
$arr = $CDE->get_value (0,  $sql, 1); //array

Hope that helps your problem

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.