include command is adding a <br /> code. help please.

Discussion in 'PHP' started by Lavish, Mar 22, 2007.

  1. #1
    Hi guys,

    I am asking kindly for a little php issue that im having. Im a newbie to php so im still getting my feet wet. :D

    But I am retreaving info from a file using the php include command. Here is the code im using.

    <?php include('fbnvideos.incl') ?>

    so my output is the info within the file as such.
    outputs: 123456789


    and it pulls the info just fine. But when I use the php coding within a link html coding like below...

    <a href="<?php include('fbnvideos.incl') ?>">TESTING</a>

    this is the output link is this
    http://mysites/123456789<br />
    Did you noitce that it added the <br /> code in the link? I think i may have figured out why it has done this. Its because in the "fbnvideos.incl" file there seems to be 2 lines. the 1st line contains the info which is: 123456789 and the 2nd line is blank.

    So the file looks like this example:
    line 1: 123456789
    line 2:

    See yow line 2 is actually blank. Is this blank causing the <br /> code to appear. How can I stop this from happening? I know the simple way of doing this would be just to go into the file and delete the 2nd empty line but I dont have permission to edit the file because its own by the "root" of the server.

    can someone please help a newbie php coder. :eek:

    thanks a million in advance.

    Lavish
     
    Lavish, Mar 22, 2007 IP
  2. The Reckoning

    The Reckoning Peon

    Messages:
    862
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Change readfile('fbnvideos.incl'); to include 'fbnvideos.incl';.
     
    The Reckoning, Mar 22, 2007 IP
  3. Lavish

    Lavish Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    hi TR and thanks for the help. I have tried require, readfile, and include. It all gives me same results. Any more help and I would be very greatful. ;)
     
    Lavish, Mar 22, 2007 IP
  4. advancedfuture

    advancedfuture Banned

    Messages:
    481
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #4
    you could try using strip_tags(); to strip the data of the <br> tags.

    so like

    <a href=<?php include(strip_tags('fbnvideos.incl')) ?>TESTING</a>

    Make sure to reumove the "" marks in your anchor text and it should work. I just tested it on my server.

    If it works don't forget the rep ^_^ =D
     
    advancedfuture, Mar 22, 2007 IP
  5. TwistMyArm

    TwistMyArm Peon

    Messages:
    931
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #5
    What browser are you using? Sometimes if the rest of your code doesn't specify the correct HTML tags (I don't know if you are actually using <html><body> to begin with) I believe IE will 'interpret' what it is given.

    Then the problem is that the 'show source' shows what it has rendered, not what it was actually sent.

    If you're using IE, try it in Firefox and see what happens as there is no real reason why that <br> is there (unless there's something weird going on in your include file).
     
    TwistMyArm, Mar 22, 2007 IP
  6. The Reckoning

    The Reckoning Peon

    Messages:
    862
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Post us the exact code you are using.
    Is this being parsed by a template system, that template system may be converting new lines to line breaks.
    Try doing trim(file_get_contents('fbnvideos.incl'));
     
    The Reckoning, Mar 22, 2007 IP