1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

php include blank space problem

Discussion in 'PHP' started by phpmania, Jul 30, 2008.

  1. #1
    Hi all
    I use this code to include a page into other one
    SEMrush
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
    <?php
    if ($num = 1){ include('1.php');}
    else{ include('error.php');}
    ?>
    PHP:
    But this code generates unwelcome blank space on the top of the page on ie but on Firefox work well!

    How can resolve this problem
    Thanks in advance
     
    phpmania, Jul 30, 2008 IP
    SEMrush
  2. selling vcc

    selling vcc Peon

    Messages:
    361
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #2
    remove the "?>"
     
    selling vcc, Jul 30, 2008 IP
  3. phpmania

    phpmania Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I can’t do this because page has continue

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
    <?php
    if ($num = 1){ include('1.php');}
    else{ include('error.php');}
    ?>
    
    some html code
    PHP:
     
    phpmania, Jul 30, 2008 IP
  4. Cri2T

    Cri2T Peon

    Messages:
    104
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Try removing all line breaks (PHP is whitespace insensitive)
     
    Cri2T, Jul 30, 2008 IP
  5. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #5
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"><?php
    if ($num = 1){ include('1.php');}
    else{ include('error.php');}
    ?> some html text here
    
    Code (markup):
    Peace,
     
    Barti1987, Jul 30, 2008 IP
  6. payu

    payu Peon

    Messages:
    40
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    in the if ($num = 1) you are assigning $num with a value 1 not a condition if $num equal to 1

    the result is ... the if condition will always return true and the statement include('1.php'); will always get executed.

    if you mean you want to compare $num with 1 try using if ($num == 1) instead
     
    payu, Jul 30, 2008 IP
  7. jack_ss

    jack_ss Guest

    Messages:
    94
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I've had this problem before. Make sure you upload your file in ASCII not Binary. Sometimes, with some FTP servers, you have to set this manually. Also try converting your newlines to "\n" in your text editor. Lemme know which editor you're using and I'll give you more specific instructions.
     
    jack_ss, Jul 30, 2008 IP
  8. phpmania

    phpmania Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Thanks all
    I solve this problem using notepad++ (http://notepad-plus.sourceforge.net/)
    Open php files with notepad++ and in Format menu chose encode in utf-8 without BOM and save it.
     
    phpmania, Jul 31, 2008 IP