PHP submits textarea data to MySQL with a number of whitespace solutions, textareamysql_php tutorial

Source: Internet
Author: User

PHP submits textarea data to MySQL with a number of whitespace solutions, textareamysql


This example explains how PHP submits textarea data to MySQL with a lot of whitespace. Share to everyone for your reference. The specific analysis is as follows:

Some friends might find that we have a lot of space when we read the data from MySQL again after HTML is submitted to PHP for processing the data into MySQL, so if we look at MySQL directly and there is no space, what is the problem?

There are always a lot of whitespace problems in textarea solution

Problem Description:

In PHP read MySQL data to textarea beginning can end there are a lot of spaces, in the data table to see the data there is no space.

Cause of the problem:

The content should be written with textarea, and do not have spaces and line breaks after textarea.

Workaround:

The code is as follows:
Copy the Code code as follows: <?php
Echo str_replace (', ', ' ab AB ');
Output "Abab"
?>
or use
Copy the Code code as follows: <?php
echo strtr (' Ab ab ', array (' ' = ') ');
Output "Abab"
?>

Add:

The line break in PHP textarea is "\ r \ n"

Not ' \ n '

Not
"

Not ' \ r \ n '

Not ' \ r ' + ' \ n '

I hope this article is helpful to everyone's PHP programming.

http://www.bkjia.com/PHPjc/930186.html www.bkjia.com true http://www.bkjia.com/PHPjc/930186.html techarticle PHP will textarea data submitted to MySQL a lot of space to solve the problem, textareamysql This article describes the PHP textarea data submitted to MySQL a lot of space to solve the problem. Share to ...

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