CodeIgniter Forums
Index.php - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Index.php (/showthread.php?tid=65008)



Index.php - davy_yg - 04-19-2016

views/cms/index.php



PHP Code:
<img src="<?php echo base_url('images/large_pic.jpg');?>" width="200px">&nbsp&nbsp<img src="<?php echo base_url();?>images/large_pic3.jpg" width="200px">&nbsp&nbsp<img src="<?php echo base_url();?>images/large_pic4.jpg" width="200px">&nbsp&nbsp<img src="<?php echo base_url();?>images/large_pic5.jpg" width="200px" height="165px">

     
            
<?php if(isset($images)) : ?>
                <?php foreach ($images as $image) : ?>
                    <?php 
                    
//do whatever you need with each image
                    echo "images";
                ?>
                <?php //endforeach; ?>
                
            <?php else : ?>
                    <?php
                    
// determine what to do if there are no images
                    echo "else images";
            ?>
            <?php endif; ?>
            


I am using Debugger and have several errors:



<img src="<?php echo base_url('images/large_pic.jpg');?>" width="200px">&nbsp&nbsp<img src="<?php echo base_url();?>images/large_pic3.jpg" width="200px">&nbsp&nbsp<img src="<?php echo base_url();?>images/large_pic4.jpg" width="200px">&nbsp&nbsp<img src="<?php echo base_url();?>images/large_pic5.jpg" width="200px" height="165px">

// undefined image file :  <?php echo base_url('images/large_pic5.jpg');?>
// undefined image file :  <?php echo base_url('images/large_pic3.jpg');?>
// undefined image file :  <?php echo base_url('images/large_pic.jpg');?>
// undefined image file :  <?php echo base_url('images/large_pic4.jpg');?>

<?php else : ?>   // syntax error unexpected else

<?php endif; ?>  // syntax error unexpected endif


Can anyone help me to fix the error next to // sign.

Thanks in advance.


RE: Index.php - InsiteFX - 04-20-2016

Look at your top image code the second image and you should see your error on the base_url().


RE: Index.php - Wouter60 - 04-20-2016

You broke up the structure by commenting the endforeach.
Remove the // in front of endforeach;
Check if you keep getting errors after that.

Next, start each image block on a new line in your php file.
It's much easier to read, and it has no effect on the way your browser handles the code. The browser will only start a new line if you deliberately insert a <br />.

Also close the <image> tag with /> at the end, with a space and a / before the >
All html-tags that don't come in pairs, like <hr />, <br />, <img /> etc. should be closed the way I show you here.