CodeIgniter Forums
displaying an image in a template - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: Model-View-Controller (https://forum.codeigniter.com/forum-10.html)
+--- Thread: displaying an image in a template (/thread-77832.html)



displaying an image in a template - richb201 - 10-23-2020

I have a view file that is being loaded with this:

$this->output->set_template('default3');

inside default3 I have this bit of code.

<?php
if ($_GET['typo']=="PHARMA"){
      echo '<script type="text/JavaScript">
      <img src="<?php echo base_url(); ?>assets/themes/default/images/new_blue_logo_sub240x240.png" style="float:left;margin-top:5px;z-index:5" alt="logo"/>
      </script>;
    }


if ($_GET['typo']=="SOFTWARE"){         <<this line is causing the error
      echo '<script type="text/JavaScript">
      <img src="<?php echo base_url(); ?>assets/themes/default/images/output-onlinepngtools (8).png" style="float:left;margin-top:5px;z-index:5" alt="logo"/>
      </script>;
    };
?>


I am trying to get either one of those two images to appear. But the second $_GET causes an error: 
Message: syntax error, unexpected 'typo' (T_STRING), expecting ',' or ';'
Why is this?


RE: displaying an image in a template - vitnibel - 10-23-2020

because there is a syntax error in the code, just missing closing quote in first echo.
and in the second too.


RE: displaying an image in a template - richb201 - 10-23-2020

thx. I modified it to:

if ($_GET['typo']=='SOFTWARE'){
echo '<script type="text/JavaScript"><img src="<?php echo base_url(); ?>assets/themes/default/images/new_blue_logo_sub240x240.png" style="float:left;margin-top:5px;z-index:5" alt="logo"/>
</script>';
}
When i run it with localhost?typo=SOFTWARE I get this error:

ERROR - 2020-10-24 04:56:43 --> Severity: Notice --> Undefined index: typo /app/application/views/themes/default3.php 136


RE: displaying an image in a template - vitnibel - 10-23-2020

It is very strange that the first check for the value of a 'typo' succeeds and the second does not.
Although it looks right, but it's hard to say something without seeing all the code.