New to ask PHP great God correct code error, a simple blog code.

Source: Internet
Author: User
Tags flock

I just contact PHP, now from Chen Hao's "0 basic PHP" to learn to do a simple blog, the code knocked out after the execution error, when I entered the title and content submitted, click on the View Log page to display "Request parameter Error", but I do not know where there is a problem. There are also some areas of the following code that do not understand, please answer:

    1. What is the role of $ok in ADD.PHP5? The few lines of code that it appears are not very understandable.

    2. if (mkdir ($folder)) and if (strlen ($result) >0) inside the code for what is the double slash? It doesn't seem to be a comment.

    3. A href= "post.php5?entry=". $entry. ' " This line of code does not understand why there is a period before and after $entry, I hope to explain the meaning of this line.

The relevant code has been attached, I hope to understand the friend help me this rookie, greatly appreciated.

Add.php5


  Create directory exception, add log failed

'; }} $fp = @fopen ($file _name, ' W '); if ($fp) {flock ($fp, LOCK_EX); $result = fwrite ($fp, $blog _str); $lock = Flock ($fp, lock_un); Fclose ($FP); } if (strlen ($result) >0) {//$ok = false; $msg = ' Log added successfully, view the log article '; Echo $msg; }}?> <title>Simple blog based on text</title>

My blog

-----I have dream ... Add a new Blog
About me I'm a php enthusiast CopyRight 2011

Style.css

body{font-size:12px;    Background-color: #c6c68c;    padding:0; Font-family:helvetica,sans-serif;}    #container {Margin-left:auto;    Margin-right:auto;    margin-top:2px;    margin-bottom:0;    padding:0;    width:760px;    Background-color: #f6f6f6; border:1px solid #000;}    #header {Margin-left:auto;    Margin-right:auto;    padding:8px;    height:80px;    Background-color: #E8F3FD;    border-bottom:1px solid #000;    font-size:16px; Font-weight:bold;}    #title {Margin-left:auto;    Margin-right:auto;    padding:8px;    height:10px;    Background-color: #E8F3FD;    border-bottom:1px solid #000; Font-style:italic;}    #left {float:left;    margin:6px 0 4px 2px;    padding:5px; width:530px;}    #right {float:right;    margin:6px 0 4px 2px;    padding:5px; width:200px;}    #blog_entry {Margin-left:auto;    Margin-right:auto;    margin-top:4px;    margin-bottom:10px;    border:1px solid #000; Background-color: #fff;}    #blog_title {border-bottom:1px solid #000; BackGround-color: #e8ecdb;    margin:0px;    padding:4px;    Font-weight:bold; font-size:13px;}    #blog_body {Margin-left:auto;    Margin-right:auto; padding:0    0 8px 0; font-size:10px;}    #blog_date {Margin-left:auto;    Margin-right:auto; padding:0    0 8px 0; font-size:10px;}    #sidebar {Margin-left:auto;    Margin-right:auto;    border:1px solid #000;    width:180px; Background-color: #fff;}    #menu_title {border-bottom:1px solid #000;    Background-color: #e8ecdb;    margin:0px;    padding:4px;    height:10px; Font-weight:bold;}    #menu_body {Margin-left:auto;    Margin-right:auto;    margin-top:4px; padding:6px;}    #footer {clear:both;    Text-align:center;    Margin-left:auto;    Margin-right:auto;    padding:8px;    height:10px;    Background-color: #e8f3fd; border-top:1px solid #000;} #err {color:red;}

Post.php5


  
   我的BLOG';echo '日志标题:'.$content_array[0];echo '
发布时间:'.date('Y-m-d H:i:s',$content_array[1]);echo "";echo $content_array[2];?>

Reply content:

I just contact PHP, now from Chen Hao's "0 basic PHP" to learn to do a simple blog, the code knocked out after the execution error, when I entered the title and content submitted, click on the View Log page to display "Request parameter Error", but I do not know where there is a problem. There are also some areas of the following code that do not understand, please answer:

    1. What is the role of $ok in ADD.PHP5? The few lines of code that it appears are not very understandable.

    2. if (mkdir ($folder)) and if (strlen ($result) >0) inside the code for what is the double slash? It doesn't seem to be a comment.

    3. A href= "post.php5?entry=". $entry. ' " This line of code does not understand why there is a period before and after $entry, I hope to explain the meaning of this line.

The relevant code has been attached, I hope to understand the friend help me this rookie, greatly appreciated.

Add.php5


  Create directory exception, add log failed

'; }} $fp = @fopen ($file _name, ' W '); if ($fp) {flock ($fp, LOCK_EX); $result = fwrite ($fp, $blog _str); $lock = Flock ($fp, lock_un); Fclose ($FP); } if (strlen ($result) >0) {//$ok = false; $msg = ' Log added successfully, view the log article '; Echo $msg; }}?> <title>Simple blog based on text</title>

My blog

-----I have dream ... Add a new Blog
About me I'm a php enthusiast CopyRight 2011

Style.css

body{font-size:12px;    Background-color: #c6c68c;    padding:0; Font-family:helvetica,sans-serif;}    #container {Margin-left:auto;    Margin-right:auto;    margin-top:2px;    margin-bottom:0;    padding:0;    width:760px;    Background-color: #f6f6f6; border:1px solid #000;}    #header {Margin-left:auto;    Margin-right:auto;    padding:8px;    height:80px;    Background-color: #E8F3FD;    border-bottom:1px solid #000;    font-size:16px; Font-weight:bold;}    #title {Margin-left:auto;    Margin-right:auto;    padding:8px;    height:10px;    Background-color: #E8F3FD;    border-bottom:1px solid #000; Font-style:italic;}    #left {float:left;    margin:6px 0 4px 2px;    padding:5px; width:530px;}    #right {float:right;    margin:6px 0 4px 2px;    padding:5px; width:200px;}    #blog_entry {Margin-left:auto;    Margin-right:auto;    margin-top:4px;    margin-bottom:10px;    border:1px solid #000; Background-color: #fff;}    #blog_title {border-bottom:1px solid #000; BackGround-color: #e8ecdb;    margin:0px;    padding:4px;    Font-weight:bold; font-size:13px;}    #blog_body {Margin-left:auto;    Margin-right:auto; padding:0    0 8px 0; font-size:10px;}    #blog_date {Margin-left:auto;    Margin-right:auto; padding:0    0 8px 0; font-size:10px;}    #sidebar {Margin-left:auto;    Margin-right:auto;    border:1px solid #000;    width:180px; Background-color: #fff;}    #menu_title {border-bottom:1px solid #000;    Background-color: #e8ecdb;    margin:0px;    padding:4px;    height:10px; Font-weight:bold;}    #menu_body {Margin-left:auto;    Margin-right:auto;    margin-top:4px; padding:6px;}    #footer {clear:both;    Text-align:center;    Margin-left:auto;    Margin-right:auto;    padding:8px;    height:10px;    Background-color: #e8f3fd; border-top:1px solid #000;} #err {color:red;}

Post.php5


  
   我的BLOG';echo '日志标题:'.$content_array[0];echo '
发布时间:'.date('Y-m-d H:i:s',$content_array[1]);echo "";echo $content_array[2];?>

What book do you read, please? Can you take a reproduced of the code in your book?

By the way, answer your question:

    1. That $ok variable doesn't seem to work at the moment, and it might be useful to record whether there was an error in the execution of the code, assign it to it false , and then display the Add success or add failure based on its value.

    2. The added comment is that the // line of code will not be executed.

    3. PHP . is used to connect strings, in your code is used to spell HTML code.
      Examples of usage:


  
   

至于你最开始说的那个出错,我想原因可能是你打代码的时候不认真,少打了一个 _ 下划线.
见:

仔细对比一下你输入的代码和你书上的代码.

楼主是个妹子

  • 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.