Why is there always more than six spaces at the beginning of the content displayed in textarea?

Source: Internet
Author: User
Use php to write your own blog program on sinaappengine. When creating or updating an article, you can use textarea to store the article content. Currently, the article content is saved to the database in plain text format. The form is like this (in write_article.php): {code...} saves the article's SQL... write your blog program in php on sina app engine. When creating or updating an article, you can use textarea to store the article content. Currently, the article content is saved to the database in plain text format.

The form is as follows (in write_article.php ):

The SQL statement for saving the article is as follows (in save_article.php ).

$content = $_POST["article_text"];// update article$sql = "update article set title=\"$title\",type=\"$category\",content=\"$content\",summary=\"$summary\",updatetime=\"$datetime\" where id=$id";... ...// save new article$sql = "insert into article values ($id, \"$category\", \"$title\", \"$author\", \"$summary\", \"$content\", \"$datetime\", \"$datetime\", $hits)";

However, when updating an article (in write_article.php), it is found that there are always six more spaces at the beginning of the text displayed in textarea. Delete spaces and submit the article. When the article is edited, it is found that there are still six more spaces at the beginning of textarea.

HoweverRead articlesNo extra spaces are found at the beginning of the article.

I cannot explain it, so I ask for help. What is the extra space?

Reply content:

Use php to write your own blog program on the sina app engine. When creating or updating an article, you can use textarea to store the article content. Currently, the article content is saved to the database in plain text format.

The form is as follows (in write_article.php ):

The SQL statement for saving the article is as follows (in save_article.php ).

$content = $_POST["article_text"];// update article$sql = "update article set title=\"$title\",type=\"$category\",content=\"$content\",summary=\"$summary\",updatetime=\"$datetime\" where id=$id";... ...// save new article$sql = "insert into article values ($id, \"$category\", \"$title\", \"$author\", \"$summary\", \"$content\", \"$datetime\", \"$datetime\", $hits)";

However, when updating an article (in write_article.php), it is found that there are always six more spaces at the beginning of the text displayed in textarea. Delete spaces and submit the article. When the article is edited, it is found that there are still six more spaces at the beginning of textarea.

HoweverRead articlesNo extra spaces are found at the beginning of the article.

I cannot explain it, so I ask for help. What is the extra space?

You</Code> there will be blank spaces and line breaks, so this will happen. The content is written with <code> <textarea> </code>, </p> <p> when saving, use <code> $ content = trim ($ _ POST ["article_text"]); </code> </p> <p> ~ </P> <p class = "answer fmt" data-id = "1020000000332993"> <p> changed: </p> <pre> <code> <textarea rows = "20" cols = "80" name = "article_text"> <? Php if ($ op = "update") {echo $ content ;}?>

Note that textarea does not contain anything redundant. Your original code contains line breaks and spaces.

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.