CodeIgniter Forums

Full Version: Index.php
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

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) : ?>
//do whatever you need with each image
                    echo "images";
                <?php //endforeach; ?>
            <?php else : ?>
// 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.
Look at your top image code the second image and you should see your error on the base_url().
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.