The variable is undefined and a warning cannot be found after a long time! Thank you for your help! At the end of this post, the variable $ arr in the while loop of row 2014 is edited by xuzuning from 0610-03-20th: 16: 20, don't lower the warning. it's self-deception. what I want is to improve ******** & lt; in the program ;? The phpse variable is undefined and a warning cannot be found after a long time! Thank you for your help!
This post was last edited by xuzuning at 10:16:20 on
/******* $ Arr in the while loop of 20th rows says it is undefined. do not lower the warning. it is self-deception, what I want is how to improve the program *******/
Session_start ();
Echo $ _ SESSION ['username'];
If ($ _ POST & $ _ POST ['submit ']) {
$ Username = $ _ POST ["username"];
$ Email = $ _ POST ["email"];
$ Title = $ _ POST ["title"];
$ Content = $ _ POST ["content"];
$ Createtime = date ("Y-m-d H: I: s ");
$ Link = mysql_connect ("127.0.1.1", "root", "") or die ("cannot connect to the server! It may be because the database server is not enabled or the user name and password are incorrect! ". Mysql_error ());
Mysql_query ("use db_leave ");
Mysql_select_db ("db_leave", $ link );
Mysql_query ("set names 'utf8 '");
$ SQL = "insert into l_text (id, username, email, title, content, createtime) values ('', '$ username',' $ email ',' $ title ', '$ content',' $ createtime ')";
$ Result = mysql_query ($ SQL );
$ R = mysql_query ("select * from l_text ");
}
?>
While ($ arr = mysql_fetch_array ($ r )){
?>
Name: |
|
Email: |
|
Title: |
|
Message time: |
|
Message content: |
|
}
?>
------ Solution --------------------
In C, variables must be declared before use (because the compiler needs to allocate memory)
Php variables are not directly stored in the memory address, but in the variable table. So you can use undeclared variables.
The Notice warning only indicates that a problem may occur, but not necessarily.
Why is database query placed outside the branch?
Because you use database operations both inside and outside the condition branch
If it is placed only in the condition branch, a problem may occur.