Php judgment statement

Source: Internet
Author: User
A condition in the php judgment statement is not written.
$ Username = trim ($ _ POST ['username']);
$ Password = trim (& _ POST ['pass']);
// Declare the SQL statement that will query the database
$ Query = "select top 6 * from WEB_VIEW where DNBH = '$ username' order by SFMonth desc ";

// Execute the SQL query and return records
$ Result = mssql_query ($ query) or die ("Data query failed:". mysql_error ());

$ NumRows = mssql_num_rows ($ result );
$ NRow = mssql_fetch_array ($ result );
If (empty ($ numRows) & $ password <> substr (row [3],-4) {echo "no data found. enter the user name and password correctly. Thank you! ";}
Else {
// Output result
}

Empty ($ numRows) & $ password <> substr (row [1]. lenth-3, 4) I mean when the query result is empty or the password entered by the user is compared with the row [1] Last 4 characters in the database, if not, an error prompt is output, ask the user to enter the user name and password again.
Error prompted during running, Parse error: syntax error, unexpected '[' in D: \ WWW \ test. php


Reply to discussion (solution)

Substr (row [3],-4)
Should be written
Substr ($ nRow [3],-4)

$ NumRows = mssql_num_rows ($ result );
$ NRow = mssql_fetch_array ($ result );
If (empty ($ numRows) | $ password <> substr (nRow [3],-4) {echo "no data found. enter the user name and password correctly. Thank you! ";}

I have already changed it.

Why do you always miss "$"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.