Jump to content

Please help with syntax


lingo5

Recommended Posts

Hi,

i,m trying to echo a "a href" based on the language session of my page like this:

 

?php if ($_SESSION['session_idioma'])=="eng"
{
	echo '<a href="preordering.php"><img src="img/top_banner_'.$_SESSION['session_idioma'].'.jpg" width="744" height="182"></a>';
}

	{
	else echo '<a href="ordering.php"><img src="img/top_banner_'.$_SESSION['session_idioma'].'.jpg" width="744" height="182"></a>'; 
	}?>

but I'm getting a blank page wit no errors...must be a syntax error that I can't spot...

Link to comment
https://forums.phpfreaks.com/topic/254084-please-help-with-syntax/
Share on other sites

<?php
         $idioma = $_SESSION['session_idioma'];
         if ($idioma == "eng") {
            ?>
	<a href="preordering.php"><img src="img/top_banner_<?php echo $idioma; ?>.jpg" width="744" height="182"></a>
            <?php
}else {
            ?>
         echo '<a href="ordering.php"><img src="img/top_banner_<?php echo $idioma; ?>.jpg" width="744" height="182"></a>
            <?php 
}
        ?>

Hi,

i,m trying to echo a "a href" based on the language session of my page like this:

 

?php if ($_SESSION['session_idioma'])=="eng"
{
	echo '<a href="preordering.php"><img src="img/top_banner_'.$_SESSION['session_idioma'].'.jpg" width="744" height="182"></a>';
}

	{
	else echo '<a href="ordering.php"><img src="img/top_banner_'.$_SESSION['session_idioma'].'.jpg" width="744" height="182"></a>'; 
	}?>

but I'm getting a blank page wit no errors...must be a syntax error that I can't spot...

your else is actualy within / after it's own opening brace...

Thanks Muddy,

I have tried with the else before the opening brace like so...

 

<?php if ($_SESSION['session_idioma'])=="eng"
{
echo '<a href="preordering.php"><img src="img/top_banner_'.$_SESSION['session_idioma'].'.jpg" width="744" height="182"></a>';
}
else 
{		
echo '<a href="ordering.php"><img src="img/top_banner_'.$_SESSION['session_idioma'].'.jpg" width="744" height="182"></a>';
}?>

 

..still no luck.

 

ayKay, tried your suggestion also but same blank page pops up...

You also have you if brackets closing too soo...

 

how about a slightly different slant on it:

<?php 

$idioma = $_SESSION['idioma'];
if ($idioma=="eng")
{
$prefix= '<a href="preordering.php"><img src="img/top_banner_';
}
else 
{		
$prefix='<a href="ordering.php"><img src="img/top_banner_';
}
$suffix = '.jpg" width="744" height="182"></a>';
$urlLink = $prefix.$idioma.$suffix;
echo "It Worked!! >>>>".$urlLink;
ehco "<br><pre>". $urlLink."</pre></br>";
?>

I flung the extra bit in there in case it's a problem with the URL for the img src.

edit to my post:

 

<?php
         $idioma = $_SESSION['session_idioma'];
         if ($idioma == "eng") {
            ?>
	<a href="preordering.php"><img src="img/top_banner_<?php echo $idioma; ?>.jpg" width="744" height="182"></a>
            <?php
}else {
            ?>
         <a href="ordering.php"><img src="img/top_banner_<?php echo $idioma; ?>.jpg" width="744" height="182"></a>
            <?php 
}
        ?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.