Php database connection problems

Source: Internet
Author: User
Php connection database problems connection database query. The problem is that I used two statements to query, one for output result $ result and the other for determining the password $ resultPass. Can I use only one statement? I have tried this before, and the latest data row is missing. The password is in the same table, and the last four digits of the data are taken and the entered password is used for determination.
Now I want to add more functions. Do I need to use a new statement to modify the data in the table? This will not affect the page response. I feel a little slow when querying data in my current page application.

$ Dbhandle = mssql_connect ($ myServer, $ myUser, $ myPass) or die ("unable to connect to database"); // select a database to work with $ selected = mssql_select_db ($ myDB, $ dbhandle) or die ("The specified database cannot be connected"); $ 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 qu Ery and return records $ result = mssql_query ($ query) or die ("Data query failed :". mysql_error (); // connects to the database and outputs the query result $ resultPass = mssql_query ($ query) or die ("Data query failed :". mysql_error (); // connect to the database to determine the password $ numRows = mssql_num_rows ($ result); $ numRowsPass = mssql_num_rows ($ resultPass ); // $ row = mssql_fetch_array ($ result); $ rowPass = mssql_fetch_array ($ resultPass); session_start (); $ ask = $ _ POST ['Ask ']; $ dbpass = trim ($ rowPass [3]); $ Dbusername = trim ($ rowPass [0]); if ($ username <> $ dbusername | $ password <> substr ($ dbpass,-4 )) {echo "entered incorrectly. please enter the user name and password correctly. Thank you! ";} Elseif ($ ask <> $ _ SESSION ['vcode']) {echo" "; echo" incorrect answer to the verification code! "; Echo 'Return '; echo" ";} else {echo $ row [4]; // $ row [0], $ row [1], $ row [2] ......} mssql_free_result ($ result); mssql_free_result ($ resultPass); mssql_close ($ dbhandle );


Reply to discussion (solution)

You write in the select statement as follows:
SUBSTRING (the field to be intercepted (password), indexStart, indexEnd) jiequA, the field to be intercepted (password)
JiequA is used to determine.

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.