7 Replies - 2365 Views - Last Post: 04 October 2009 - 07:32 AM Rate Topic: -----

#1 helenryle  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 25-September 09

how to insert a new line in an inc file in php

Posted 25 September 2009 - 03:49 AM

Hello,
I'd be grateful if you would kindly advise me? I have a php guestbook on my website, it's at http://www.costasolr...om/costa_gb.php. I've disabled the automatic posting feature because of spammers so now manually edit the .inc entries file and file counter file when guests send me a testimonial to add to the guestbook.

My difficulty is that when I type in the guestbook entry into the .inc file and upload it, no paragraphs or new lines are shown, the text all runs together.

So far, I have tried adding <br><p> and <pre> with no result at all, and when I add either "\n" or '\n' into the code this is the error message the webpage shows (line 140 being where I've added either form of \n):

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /home/content/h/y/p/hypnos7/html/entries.inc on line 140

Parse error: parse error, unexpected T_STRING, expecting ')' in /home/content/h/y/p/hypnos7/html/entries.inc on line 140.


Here is the most recent entry exactly as I added it to the entries.inc file, you can see how it shows up on the webpage at http://www.costasolr...om/costa_gb.php. Would you kindly advise how I might get the paragraphs or new lines to show?

<? $entry47 = Array ( 'Name' => 'Bernard Byrne', 'E-Mail' => 'bernardjewel@msn.com', 'Posted' => 'Thursday 24th September 2009', 'Site URL' => '', 'Message' => 'Many thanks for the use of your holiday apartment in Cabopino. We all arrived home safe and rested after a very enjoyable holiday, the apartment was perfect for  holiday requirements for all our family. We particularly loved the large terrace and were pleasantly surprised that the lovely garden and pool were literally on our doorstep... we had the pool to ourselves 8 out of 9 days! 
Cabopino is really lovely, the marina is beautiful and the beach is the best in the area. 
I don\'t like to drive on the "other side of the road" but this didn\'t cause a problem as the bus service is excellent and very cheap, we visited nearby Calahonda, Fuengirola and beautiful Marbella all by bus. 
The airport pick up service was great and Sue and Gary were both friendly and informative, a big thank you to a nice couple! 
The apartment rental represented great value for money and I would recommend same to any family considering the area for a pleasant, safe and enjoyable holiday in the sun.
 Kind Regards,
Bernard, Annette and Jessica.
Kildare, Ireland. '); ?>


Many thanks for your help,
Best wishes from Ireland,
Helen Ryle
www.costasolrental.com

Is This A Good Question/Topic? 0
  • +

Replies To: how to insert a new line in an inc file in php

#2 thehat  Icon User is offline

  • awake ? web();
  • member icon

Reputation: 106
  • View blog
  • Posts: 951
  • Joined: 28-February 08

Re: how to insert a new line in an inc file in php

Posted 25 September 2009 - 04:09 AM

I think you should use speech marks (" ") to wrap your text. PHP will ignore line breaks and other character in strings wrapped with single quotes (' '). Using speech marks and <br> tags worked for me:
<?php
$entry47 = Array ( 'Name' => 'Bernard Byrne', 'E-Mail' => 'bernardjewel@msn.com', 'Posted' => 'Thursday 24th September 2009', 'Site URL' => '', 'Message' => "Many thanks for the use of your holiday apartment in Cabopino. We all arrived home safe and rested after a very enjoyable holiday, the apartment was perfect for  holiday requirements for all our family. We particularly loved the large terrace and were pleasantly surprised that the lovely garden and pool were literally on our doorstep... we had the pool to ourselves 8 out of 9 days!
Cabopino is really lovely, the marina is beautiful and the beach is the best in the area.<br>
I don't like to drive on the \"other side of the road\" but this didn't cause a problem as the bus service is excellent and very cheap, we visited nearby Calahonda, Fuengirola and beautiful Marbella all by bus.<br>
The airport pick up service was great and Sue and Gary were both friendly and informative, a big thank you to a nice couple!<br>
The apartment rental represented great value for money and I would recommend same to any family considering the area for a pleasant, safe and enjoyable holiday in the sun.<br>
 Kind Regards,<br>
Bernard, Annette and Jessica.<br>
Kildare, Ireland. ");
?>



I then just used echo to display the text.

This post has been edited by thehat: 25 September 2009 - 04:35 AM

Was This Post Helpful? 0
  • +
  • -

#3 helenryle  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 25-September 09

Re: how to insert a new line in an inc file in php

Posted 29 September 2009 - 06:52 AM

Hello again,
Many thanks for your reply to my post. I've been away for a few days so just got the chance to copy and paste the code snippet you kindly sent me to the guestbook today.
However, it is still showing up the same, without line breaks (see http://www.costasolr...m/costa_gb.php). There are 2 entries now, my original one and the result when I copied and pasted your code into the entries.inc file.
You mentioned speech marks - can you advise where I should put them in the code below please?
<?php
$entry48 = Array ( 'Name' => 'Bernard Byrne', 'E-Mail' => 'bernardjewel@msn.com', 'Posted' => 'Thursday 24th September 2009', 'Site URL' => '', 'Message' => "Many thanks for the use of your holiday apartment in Cabopino. We all arrived home safe and rested after a very enjoyable holiday, the apartment was perfect for  holiday requirements for all our family. We particularly loved the large terrace and were pleasantly surprised that the lovely garden and pool were literally on our doorstep... we had the pool to ourselves 8 out of 9 days!
Cabopino is really lovely, the marina is beautiful and the beach is the best in the area.<br>
I don't like to drive on the \"other side of the road\" but this didn't cause a problem as the bus service is excellent and very cheap, we visited nearby Calahonda, Fuengirola and beautiful Marbella all by bus.<br>
The airport pick up service was great and Sue and Gary were both friendly and informative, a big thank you to a nice couple!<br>
The apartment rental represented great value for money and I would recommend same to any family considering the area for a pleasant, safe and enjoyable holiday in the sun.<br>
Kind Regards,<br>
Bernard, Annette and Jessica.<br>
Kildare, Ireland. ");
?>


Many thanks for taking the time to help a newbie,
Best wishes from Ireland,
Helen
Was This Post Helpful? 0
  • +
  • -

#4 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6063
  • View blog
  • Posts: 23,516
  • Joined: 23-August 08

Re: how to insert a new line in an inc file in php

Posted 29 September 2009 - 06:57 AM

You could try running the function nl2br() on the text.
Was This Post Helpful? 0
  • +
  • -

#5 Ishbir  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 29-September 09

Re: how to insert a new line in an inc file in php

Posted 29 September 2009 - 07:33 AM

The function nl2br() as mentioned by JackOfAllTrades would be perfect. Run it just before saving it in the file.
Was This Post Helpful? 0
  • +
  • -

#6 helenryle  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 25-September 09

Re: how to insert a new line in an inc file in php

Posted 04 October 2009 - 04:19 AM

Thanks for your suggestion,
I'm a complete novice with php but am going to try to implement the function you suggest with the help of the examples on the link you provided. Will post again and let you know how I get on!
Best wishes, Helen

View PostJackOfAllTrades, on 29 Sep, 2009 - 05:57 AM, said:

You could try running the function nl2br() on the text.

Was This Post Helpful? 0
  • +
  • -

#7 helenryle  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 25-September 09

Re: how to insert a new line in an inc file in php

Posted 04 October 2009 - 04:24 AM

View PostIshbir, on 29 Sep, 2009 - 06:33 AM, said:

The function nl2br() as mentioned by JackOfAllTrades would be perfect. Run it just before saving it in the file.


Hello again,
Thanks for the additional info. When I edit the .inc file in Dreamweaver (in code view), I just save the changes and then upload it by FTP. Can you advise what I need to do to run it before saving the file as you suggest?
My apologies, but I am a complete novice at any coding except html.
Best wishes, Helen
Was This Post Helpful? 0
  • +
  • -

#8 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6063
  • View blog
  • Posts: 23,516
  • Joined: 23-August 08

Re: how to insert a new line in an inc file in php

Posted 04 October 2009 - 07:32 AM

What he/she means is you need to run the comment text through the nl2br function either before saving it to wherever you save this information, or before displaying it to the end user.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1