The variable is undefined and a warning cannot be found after a long time! Thank you for your help.

Source: Internet
Author: User
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.

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.