New line
Moderator: General Moderators
New line
I am making (attempting!) a database to store news entries, when I run a query to retrieve everything (select * from etc..) it leaves a blank space where the line should be.
Does anyone know how to make it keep the line when formatting?
The data type is 'blob' if that helps
Thanks.
Does anyone know how to make it keep the line when formatting?
The data type is 'blob' if that helps
Thanks.
Whoops, sorry.
If I input
Hello
World!
It will output as "Hello World!"
Code: Select all
<?
$time = $_POSTї"time"];
$subject = $_POSTї"subject"];
$news = $_POSTї"news"];
$dbcnx = @mysql_connect("localhost", "user", "pass") .
mysql_select_db("blog");
$add = "INSERT INTO news (time, subject, content) VALUES ('$time', '$subject', '$news')";
$added = mysql_query($add);
$test = mysql_connect("localhost", "root", "") or die ("Something's wrong");
mysql_select_db("blog") or die ("Something is wrong");
$result = mysql_query("SELECT * FROM news");
while ($row = mysql_fetch_array($result) ) {
echo($rowї"id"] . " " . $rowї"time"] . " " . $rowї"subject"] . " " . $rowї"content"] . "<br>");
}
?>Hello
World!
It will output as "Hello World!"
Yep, just entered some sample data then
"testing!!!!
123"
(in that spacing / line configuration)
And ran the query from the mysql command line program, it output:
That looks right to me (it was the data I entered, and the line is in there), although should the formatting of the table be correct?
Thank you
"testing!!!!
123"
(in that spacing / line configuration)
And ran the query from the mysql command line program, it output:
Code: Select all
mysql> select news from news where id=7;
+------------------+
| content |
+------------------+
| testing!!!!
123 |
+------------------+Thank you
- hob_goblin
- Forum Regular
- Posts: 978
- Joined: Sun Apr 28, 2002 9:53 pm
- Contact:
Try this:
Code: Select all
<?
$time = $_POSTї"time"];
$subject = $_POSTї"subject"];
$news = $_POSTї"news"];
$dbcnx = @mysql_connect("localhost", "user", "pass") .
mysql_select_db("blog");
$add = "INSERT INTO news (time, subject, content) VALUES ('$time', '$subject', '$news')";
$added = mysql_query($add);
$test = mysql_connect("localhost", "root", "") or die ("Something's wrong");
mysql_select_db("blog") or die ("Something is wrong");
$result = mysql_query("SELECT * FROM news");
while ($row = mysql_fetch_array($result) ) {
echo(nl2br($rowї"id"] . " " . $rowї"time"] . " " . $rowї"subject"] . " " . $rowї"content"] . "<br>"));
}
?>Thank you very much, this fixed my problems. what does the nl2br do? I havent come across that in my reading.hob_goblin wrote:Code: Select all
echo(nl2br($rowї"id"] . " " . $rowї"time"] . " " . $rowї"subject"] . " " . $rowї"content"] . "<br>"));
PS, sorry about the delay in my reply, I have been busy and am sick :/
- mydimension
- Moderator
- Posts: 531
- Joined: Tue Apr 23, 2002 6:00 pm
- Location: Lowell, MA USA
- Contact:
in short, in appends a "<br />" onto every newline it encounters. read http://www.php.net/nl2br for more details
Very useful, thanks. I'll make a note of itmydimension wrote:in short, in appends a "<br />" onto every newline it encounters. read http://www.php.net/nl2br for more details