-1
我从我的数据库中读取了一个文本,它有多行并存储在一个变量中。 当我在我的网页上输出这个变量时,它全部打印在一行中。 如何在不同的行输出。不输出换行符
<?php
$num=$_GET['id'];
$result=mysql_query("SELECT * FROM messages WHERE id='$num'");
$row=mysql_fetch_array($result);
$msg=$row['message'];
?>
message:<br/><?php echo $msg;?>//Here I need to print message in multiple
//lines as entered in the database.
使用[nl2br](http://php.net/manual/en/function.nl2br.php) –
***请[停止使用'mysql_ *'函数](http://stackoverflow.com/questions /12859942/why-shouldnt-i-use-mysql-functions-in-php).*** [这些扩展程序](http://php.net/manual/en/migration70.removed-exts-sapis.php)已在PHP 7中删除。了解[准备](http://en.wikipedia.org/wiki/Prepared_statement)[PDO]的声明(http://php.net/manual/en/pdo.prepared-statements .php)和[MySQLi](http://php.net/manual/en/mysqli.quickstart.prepared-statements.php)并考虑使用PDO,[这真的很简单](http://jayblanchard.net/ demystifying_php_pdo.html)。 –
[Little Bobby](http://bobby-tables.com/)说*** [你的脚本存在SQL注入攻击风险。](http://stackoverflow.com/questions/60174/how-can- I-防止-SQL注入式-PHP)***。即使[转义字符串](http://stackoverflow.com/questions/5741187/sql-injection-that-gets-around-mysql-real-escape-string)是不安全的! –