The demo of json data returned by php is as follows. what causes this problem?

Source: Internet
Author: User
{Code...} php returns json data. if {code...} is contained in this line of code ajax, an error is returned. If this line of code is removed, the ajax result is successhtml code as follows: {code ...}

  query("select id from user2 where name = 'admin' and password ='admin'");//$user_details = $db->get_row(null, OBJECT, 0);//var_dump($user_details) ;$sql = sprintf("select * from user2 where name='%s' and password='%s'",$username,$password);//echo $sql;//select * from user2 where name='admin' and password='admin'$user=$db->get_results($sql);//var_dump($user);//array(1) { [0]=> object(stdClass)#5 (3) { ["id"]=> string(1) "1" ["name"]=> string(5) "admin" ["password"]=> string(5) "admin" } }if($user){  $result='0';   }else{   $result='-1';  }$arr = array ('a'=>1,'b'=>2,'c'=>3,'d'=>4,'e'=>5);echo json_encode($arr);?>

Php returns json data, if it contains

$user=$db->get_results($sql);  

This line of code ajax returns error.

If this line of code is removed, the ajax result is success.

The html code is as follows:

            
          
          
          
          
          
          British I2Active        
          
          
          
          

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.