php wrote a login, server error 500.

Source: Internet
Author: User
The code is as follows:
Table structure

id         int phone      charpassword   char

conn.php


  
   错误原因:'.mysql_error());    //设置字符集,如utf8和gbk等    mysql_query("set names 'utf8'");    //选定数据库    mysql_select_db($db_name,$conn) or die('数据库选定失败!
错误原因:'.mysql_error()); //执行SQL语句(查询) //$result = mysql_query($sql) or die('数据库查询失败!
错误原因:'.mysql_error());?>

login.php


  ' Unlawful request ');        return false; }//Create SQL statement $sql = "SELECT * from lms_users WHERE phone = '". $userName. "'            and ' password ' = ' ". $userPassword." '; ";        Call the conn.php file for database operation require (' conn.php ');                Global $conn;                $result =mysql_query ($sql, $conn) or Die (' database query failed! ' ERROR reason: '. mysql_error ());        $flag = 0; while (!!        $item =mysql_fetch_assoc ($result)) {$flag + +;        };        Only one result can actually 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 测试    

登陆

Reply content:

The code is as follows:
Table structure

id         int phone      charpassword   char

conn.php


  
   错误原因:'.mysql_error());    //设置字符集,如utf8和gbk等    mysql_query("set names 'utf8'");    //选定数据库    mysql_select_db($db_name,$conn) or die('数据库选定失败!
错误原因:'.mysql_error()); //执行SQL语句(查询) //$result = mysql_query($sql) or die('数据库查询失败!
错误原因:'.mysql_error());?>

login.php


  ' Unlawful request ');        return false; }//Create SQL statement $sql = "SELECT * from lms_users WHERE phone = '". $userName. "'            and ' password ' = ' ". $userPassword." '; ";        Call the conn.php file for database operation require (' conn.php ');                Global $conn;                $result =mysql_query ($sql, $conn) or Die (' database query failed! ' ERROR reason: '. mysql_error ());        $flag = 0; while (!!        $item =mysql_fetch_assoc ($result)) {$flag + +;        };        Only one result can actually 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 测试    

登陆

The development of the words to open the wrong display of PHP (in the php.ini search configuration display_errors=On ) in order to know what the specific error.

In addition, it is recommended not to use related functions mysql , with mysqli related functions or objects instead, the mysql correlation function is not recommended, and in the latest PHP7 formally removed.

It's a grammatical error,

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

Here is the wrong one. Can actually open the server on the detailed error output, so you can see the 500 error specific cause of the error

  • 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.