I have this <divs> that cannot read the end </divs> and when i erase the php that is in between them it works perfect..
heres the php
(when i say read i mean when u click in div in notepad++ they both <div></div> highlight , is just i dont know how u guys say it... )
i mainly speak spanish so sorry for my bad english

    <?php

        if (file_exists($rand1.$rand2.$imgname)) {
        echo      '<img id=imagen src="'.$rand1.$rand2.$imgname .'" >';


        echo '<br><div class="fb-like" data-href="http://example.com/fotos/foto'
        .$random1.$random2.$fotonamesinextension.'.php" data-layout="button_count" data-action="like" data-show-faces="true" data-share="true"></div>';

        echo '<br><br>';
        echo '<div style="margin-top:70px;" class="fb-comments" 
        data-href="http://example.com/fotos/foto' .$random1.$random2.$fotonamesinextension.'.php" 
        data-numposts=5 data-colorscheme=light></div>';


              }

        else {    
        echo '<div id="cargaexitosa">';
        echo  '<font color=green>Carga exitosa, verificaremos la imagen y pronto estara en linea! Gracias por compartir con nosotros! :)</font>';
        echo '</div>';
        }
        ?>

    </div> <!-- this div cannot be readed  -->
    </div> <!-- neither this one -->
</body>
</html>

Any ideas? Thanks!

Notepad++ will not be able to detect it, but not all the time. A good IDE like NetBeans is capable of detecting those embedded <div> tags.

Notepad++ can surely detect this type of coding technique.

<?php

function doSomething(){

return array('home'=>'Home', 'about'=>'About','contact'=>'Contact');

}

function doItAgain(){

return array('Home','About','Contact');

}

 $x = doSomething();
 $y = doItAgain();

?>

<html>
<head>
</head>
<body>
    <div>
    <ul>
    <li> <?php echo $x['home'];?> </li>
    <li> <?php echo $x['about'];?> </li>
    <li> <?php echo $x['contact'];?> </li>
    </ul>
    </div>

    <!-- second group of codes here -->

</body>
</html>

and this one, it won't be able to ..

   <br/>

    <ul>
    <!-- notepad++ will not be able to detect codes below -->
    <?php
    foreach($y as $item){
    echo '<li>'.$item.'</li>';
    }

    echo '</ul>';
    ?>

Change your br tags <br />
You really don't need brake tags after div's.. divs are block elements. If you want spacing between div's you should use CSS styling.
Looks like you are missing a forward slash in your href.
<font> is not really used anymore. should use CSS style for this. You could use <span style="color:green;"><span> instead of <font>

The div that can not be read, Where is the opening div? Need to see all the code for the section.

Member Avatar for diafol

@centenond

In addition to some comments above, I would suggest writing plain html and adding bits of php as opposed to the other way around... An example...

<?php
    //...other code (I assume)

    $src = $rand1.$rand2.$imgname;
    $url = "http://example.com/fotos/foto$random1$random2$fotonamesinextension.php";
?>

<!doctype html> 
<html>
<head>
<style>
    .fb-comments{
        margin-top: 70px;       
    }
    .green{
        color: green;   
    }
</style> 
</head>
<body>
<div> <!-- I'm assuming that there must be an outer open div tag somewhere -->
    <div> <!-- also assuming that this exists somewhere -->

        <?php
        if (file_exists($src)) {            
        ?>
        <img id="imagen" src="<?php echo $src;?>" />
        <div class="fb-like" data-href="<?php echo $url;?>" data-layout="button_count" data-action="like" data-show-faces="true" data-share="true">
        </div>
        <div class="fb-comments" class="fb-comments" data-href="<?php echo $url;?>" data-numposts="5" data-colorscheme="light">
        </div>';
        <?php
        } else {    
        ?> 
        <div id="cargaexitosa">
            <p class="green">Carga exitosa, verificaremos la imagen y pronto estara en linea! Gracias por compartir con nosotros! :)</p>
        </div>';
        <?php
        }
        ?>

    </div> <!-- this div cannot be readed  -->
</div> <!-- neither this one -->

</body>
</html>

I generally don't like mixing so much php and html and try to keep them as separate as possible. If you find that you're doing a lot of it, you may consider templating.

Yes there are oppening divs and more code i just didnt wantd to bored u with all the code as i thought the php was the problem.. but after reading veedeo reply i cheq if the divs still work property , it works property anyways it just won hightlight so im thinking is notepad++, but thanks every one, will update my code as u guys sugested , Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.