我有一个输入文本区域,我想将用户在文本区域中输入的换行符存储到数据库中,以便输出文本与输入文本相同。例如:
这是我的当前上传脚本:
Some text some text some text some text
new line some text some text new line
new line some text new line some text
这是我的当前上传脚本:
$sql = "insert into people (price, contact, category, username, fname, lname, expire, filename) values (:price, :contact, :category, :user_id, :fname, :lname, now() + INTERVAL 1 MONTH, :imagename)";
$q = $conn->prepare($sql) or die("failed!");
$q->bindParam(':price', $price, PDO::PARAM_STR);
$q->bindParam(':contact', $contact, PDO::PARAM_STR);
$q->bindParam(':category', $category, PDO::PARAM_STR);
$q->bindParam(':user_id', $user_id, PDO::PARAM_STR);
$q->bindParam(':fname', $fname, PDO::PARAM_STR);
$q->bindParam(':lname', $lname, PDO::PARAM_STR);
$q->bindParam(':imagename', $imagename, PDO::PARAM_STR);
$q->execute();
nl2br
,即nl2br($imagename);
。 - turbonerd