Variable undefined and a warning, looking for a long time also can not find out! Ask God for help, thanks.

Source: Internet
Author: User
Variable undefined and a warning, looking for a long time also can not find out! Ask the great God for help, thank you!
This post was last edited by xuzuning on 2014-03-06 10:16:20

/******* in the 20th row of the while loop inside the variable $arr said undefined, do not reduce the warning, it is self-deception, I want to be 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 ("", "Root", "") or Die ("Cannot connect to the server! The database server may not be turned on, or the user name password is wrong! ". 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: Mailbox: Title: Message time:
      Message content:

    • }

In C, variables must first be declared and reused (because the compiler needs to allocate memory)
PHP variables are not stored directly in the memory address, but are stored in the variable table. Therefore, you can use undeclared variables
Notice warning only indicates that there may be a problem, but not necessarily a problem

Why are database queries outside the branch?
Because you used database operations both inside and outside the conditional branch
If it is placed only within the conditional branch, it may be a problem
  • 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: 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.