Imitate the Hanshunping teacher to do the web chat system, the great God help see what the problem

Source: Internet
Author: User
chatroom.php******
 
 
  
 
 
  
 
   

Web chat room ( being and chatting)


getmessagecontroller.php******** GetMessage ($getter, $sender); echo $messageList;? >*********messageservice.class.php******** EXECUTE_DML ($sql);} function GetMessage ($getter, $sender) {$sql = "SELECT * from messages where getter= ' $getter ' and sender= ' $sender ' and IsG Et=0 "; $sqlHelper =new sqlHelper (); $array = $sqlHelper->execute_dql2 ($sql); $messageInfo = " "; for ($i =0; $i close_connect (); return $messageInfo; }}?>

The great God help to see where the problem is?


Reply to discussion (solution)

Didn't look carefully. Single sentence: Session_Start ();
Because there is an HTML tag in front of the output, there will definitely be "headers already sent" error, right?

You didn't tell me what was wrong with you.

Didn't look carefully. Single sentence: Session_Start ();
Because there is an HTML tag in front of the output, there will definitely be "headers already sent" error, right?

You didn't tell me what was wrong with you.


function GetMessage () {//Create a XMLHttpRequest object var myxmlhttprequest=getxmlhttpobject ();     if (myxmlhttprequest) {var url= "getmessagecontroller.php"; var data= "getter=
 &sender=
 ";     Myxmlhttprequest.open ("Post", url,true);     Myxmlhttprequest.setrequestheader ("Content-type", "application/x-www-form-urlencoded"); Myxmlhttprequest.onreadystatechange=function () {if (myxmlhttprequest.readystate==4) {if (myxmlhttprequest.status          ==200) {//NOTE 1 window.alert ("AAA");          var mesres=myxmlhttprequest.responsexml;          var cons=mesres.getelementsbytagname ("Con");          var sendtimes=mesres.getelementsbytagname ("Sendtime");          Note 2 Window.alert ("BBB"); if (cons.length!=0) {for (Var i=0;i
   
  
The main problem is the callback function, the response at note 1, but the Window.alert at note 2 will not be able to respond. The great God help to see.

It's important to write robust code.

.... if (myxmlhttprequest.status==200) {  var mesres=myxmlhttprequest.responsexml;  if (Mesres.xml = = ") {//If it is not an XML object    alert (myxmlhttprequest.responsetext);//See what return is returned    ;  } ....

This estimate is also a appearance bar, the performance is relatively poor.
Chat rooms, using websockeet or comet,
Second, you don't have to use a database, Redis or file storage to

It's important to write robust code.

.... if (myxmlhttprequest.status==200) {  var mesres=myxmlhttprequest.responsexml;  if (Mesres.xml = = ") {//If it is not an XML object    alert (myxmlhttprequest.responsetext);//See what return is returned    ;  } ....

Thank you, has been solved, blame me careless, originally is MessageService.class.php, the second header () semicolon written a colon, dizzy dead ah!

This estimate is also a appearance bar, the performance is relatively poor.
Chat rooms, using websockeet or comet,
Second, you don't have to use a database, Redis or file storage to

Well, thank you.

Header ("Cache-control:no-cache"):
This kind of mistake, the hint should be obvious.

Thank you, has been solved, blame me careless, originally is MessageService.class.php, the second header () semicolon written a colon, dizzy dead ah!

My mistake is the same as yours, but MessageService.class.php didn't use the header ()??

  • Related Article

    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.