Hi everyone, I have the following code in an include: <?php $itemSwatchBoth = $item['itemSwatchBoth']; $itemSwatchFemale = $item['itemSwatchFemale']; $itemSwatchMale = $item['itemSwatchMale']; if (($itemSwatchFemale != "") && ($itemSwatchMale != "")) echo "<p><img src="../../../../images/shirts_blouses/swatches/{$itemSwatchFemale} border="0" alt="" /></p>" . "<p><img src="../../../../images/shirts_blouses/swatches/{$itemSwatchMale} border="0" alt="" /></p>"; elseif ($itemSwatchFemale != "") echo "<p><img src="../../../../images/shirts_blouses/swatches/{$itemSwatchFemale} border="0" alt="" /></p>"; elseif ($itemSwatchMale != "") echo "<p><img src="../../../../images/shirts_blouses/swatches/{$itemSwatchMale} border="0" alt="" /></p>"; elseif ($itemSwatchBoth != "") echo "<p><img src="../../../../images/shirts_blouses/swatches/{$itemSwatchBoth} border="0" alt="" /></p>"; else echo ""; ?> PHP: When I test I get the following error: Parse error: syntax error, unexpected '.' in /Applications/MAMP/htdocs/new_site/includes/item_swatches.inc.php on line 8 Line 8 is: echo "<p><img src="../../../../images/shirts_blouses/swatches/{$itemSwatchFemale} border="0" alt="" /></p>" . "<p><img src="../../../../images/shirts_blouses/swatches/{$itemSwatchMale} border="0" alt="" /></p>"; PHP: I'm pretty sure it's to do with having to escape some quotes but I'm not sure which one. Does anyone know what the problem might be? Appreciate any help.
Try: <?php $itemSwatchBoth = $item['itemSwatchBoth']; $itemSwatchFemale = $item['itemSwatchFemale']; $itemSwatchMale = $item['itemSwatchMale']; if (($itemSwatchFemale != "") && ($itemSwatchMale != "")) { echo "<p><img src=\"../../../../images/shirts_blouses/swatches/{$itemSwatchFemale} border=\"0\" alt=\"\" /></p>\" . \"<p><img src=\"../../../../images/shirts_blouses/swatches/{$itemSwatchMale} border=\"0\" alt=\"\" /></p>"; } elseif ($itemSwatchFemale != "") { echo "<p><img src=\"../../../../images/shirts_blouses/swatches/{$itemSwatchFemale} border=\"0\" alt=\"\" /></p>"; } elseif ($itemSwatchMale != "") { echo "<p><img src=\"../../../../images/shirts_blouses/swatches/{$itemSwatchMale} border=\"0\" alt=\"\" /></p>"; } elseif ($itemSwatchBoth != "") { echo "<p><img src=\"../../../../images/shirts_blouses/swatches/{$itemSwatchBoth} border=\"0\" alt=\"\" /></p>"; } else { echo ""; } ?> PHP:
have to escape " inside of "'s (and you left out the " for the end of the src attribute) echo "<p><img src=\"../../../../images/shirts_blouses/swatches/{$itemSwatchFemale}\" border=\"0\" alt=\"\" /></p>" . "<p><img src=\"../../../../images/shirts_blouses/swatches/{$itemSwatchMale}\" border=\"0\" alt=\"\" /></p>";