Php simple chat room for help! & Lt ;? Php & nbsp; session_start (); & nbsp ;? & Gt; & lt ;! DOCTYPEhtmlPUBLIC & quot;-W3CDTDHTML4.01TransitionalEN & quot; www. w3.orgTRhtml4loose. php simple chat room for help!
Session_start ();
?>
Speech page
If (isset ($ _ POST ["text_color"]) {
Switch ($ _ POST ["text_color"]) {
Case "red ":
$ Color = "red ";
Break;
Case "blue ":
$ Color = "blue ";
Break;
Case "gray ":
$ Color = "gray ";
Break;
Default:
$ _ Color = "black ";
Break;
}
}
If (isset ($ _ POST ["text"]) {
$ Con = mysql_connect ("localhost", "root", "123456 ");
Mysql_select_db ("usermembers", $ con );
Mysql_query ("set names 'gb2312 '");
$ Spokeman = $ _ SESSION ["user"];
$ Text = $ _ POST ["text"];
$ Nowtime = date ('Y-m-d-H: I: S', time ());
$ SQL = "insert into discussions (color, spokeman, spokecontent, spokedate)
Values ('$ color',' $ spokeman ',' $ text', '$ nowtime ')";
Mysql_query ($ SQL, $ con );
}
?>
For help, why can't I write data to the database for the first time and display it on the chat page? Thank you! The second time there was no information record in the database!
------ Solution --------------------
Is there a problem with the database field settings? Whether the id is set to int auto increment.