Php writes a login, and the server reports an error of 500.

Source: Internet
Author: User
The Code is as follows: The table structure authorization code ...w.conn.php?code ...?login.php=code ...?login.html {code:
Table Structure

id         int phone      charpassword   char

Conn. php


  Error cause :'. mysql_error (); // sets the character set, such as utf8 and gbk mysql_query ("set names 'utf8'"); // select the database mysql_select_db ($ db_name, $ conn) or die ('database selection failed!
Error cause: '. mysql_error (); // execute the SQL statement (query) // $ result = mysql_query ($ SQL) or die ('database query failed!
Error cause: '. mysql_error ();?>

Login. php


  'Invalid request'); return false;} // create an SQL statement $ SQL = "SELECT * FROM lms_users WHERE phone = '". $ userName. "'AND 'Password' = '". $ userPassword. "';"; // call conn. PHP file for database operation require ('conn. php '); global $ conn; $ result = mysql_query ($ SQL, $ conn) or die ('database query failed! Error cause: '. mysql_error (); $ flag = 0; while (!! $ Item = mysql_fetch_assoc ($ result) {$ flag ++ ;}; // only one result can be returned. if ($ flag> = 1) {$ result = array (echo json_encode ($ row); echo json_encode ($ result); exit ();} else {$ result = array ('id' => 0); echo json_encode ($ result);} return true;?>

Login.html

    
      PHP Testing    

Login

Reply content:

The Code is as follows:
Table Structure

id         int phone      charpassword   char

Conn. php


  Error cause :'. mysql_error (); // sets the character set, such as utf8 and gbk mysql_query ("set names 'utf8'"); // select the database mysql_select_db ($ db_name, $ conn) or die ('database selection failed!
Error cause: '. mysql_error (); // execute the SQL statement (query) // $ result = mysql_query ($ SQL) or die ('database query failed!
Error cause: '. mysql_error ();?>

Login. php


  'Invalid request'); return false;} // create an SQL statement $ SQL = "SELECT * FROM lms_users WHERE phone = '". $ userName. "'AND 'Password' = '". $ userPassword. "';"; // call conn. PHP file for database operation require ('conn. php '); global $ conn; $ result = mysql_query ($ SQL, $ conn) or die ('database query failed! Error cause: '. mysql_error (); $ flag = 0; while (!! $ Item = mysql_fetch_assoc ($ result) {$ flag ++ ;}; // only one result can be returned. if ($ flag> = 1) {$ result = array (echo json_encode ($ row); echo json_encode ($ result); exit ();} else {$ result = array ('id' => 0); echo json_encode ($ result);} return true;?>

Login.html

    
      PHP Testing    

Login

For Development, You need to enable the php error display (inphp.iniSearch Configurationdisplay_errors=On.

We recommend that you do not usemysqlRelated functions.mysqliReplace related functions or objects,mysqlRelated functions are not recommended for a long time and are removed in the latest PHP7.

There are syntax errors,

$result = array(    echo json_encode($row););                       

This is incorrect. In fact, you can open the detailed error output on the server, so that you can see the specific error cause of 500.

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.