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.