Welcome Guest, Not a member yet? Register   Sign In
displaying an image in a template
#1

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?
proof that an old dog can learn new tricks
Reply
#2

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

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
proof that an old dog can learn new tricks
Reply
#4

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.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB