Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 177
  • Last Modified:

Apostrophe in HERDOC

I have a table that is being built with HEREDOC.  I am using CS6 Dreameaver.  If I have an apostrophe I get and error...if I do this, the error goes away....

food is essentially "'"peasant"'" cuisine

Open in new window


But the problem is that it also shows that way on the live web page.  How can I handle this?
0
DS928
Asked:
DS928
  • 4
  • 3
1 Solution
 
Dave BaldwinFixer of ProblemsCommented:
You have something else going on.  This simple test works with both single and double quotes in the HEREDOC string.  If you post your code, maybe we can help figure it out.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<title>HEREDOC test</title>
</head>
<body>
<h1>HEREDOC test</h1>
<?php 
$str = <<<EOD
Example of string
spanning multiple lines
using heredoc syntax.
EOD;

echo $str."<br>";

$str2 = <<<EOD2
Example of string's
spanning multiple lines
using "heredoc" syntax.
EOD2;

echo $str2."<br>";
 ?>
</body>
</html>

Open in new window

http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc
0
 
DS928Author Commented:
Here is one page.  Almost at the end.  The word Latvia's.  If I leave it as Latvia's everything after the apsotrophe turns red in error.  If I do this Latvia"'"s the error goes away but it doesn't look right on the webpage.  The webpage.... www.menuhead.com/feedyourhead.php

Select Baltic States.


<?php
include('config.php');
$Alpha=$_POST['Alpha']= mysql_real_escape_string($_POST['Alpha']);
?>
<?php
error_reporting(E_ALL);

$html = <<<EOD

<table width="930" border="0" cellpadding="0" cellspacing="0" id="Flags" align="center">
	      
          <tr>
	        <td width="10" bgcolor="#FFFFFF">&nbsp;</td>
	        <td colspan="9" bgcolor="#FFFFFF"><h1 align="left"><strong>Baltic States</strong></h1></td>
	        <td width="10" bgcolor="#FFFFFF">&nbsp;</td>
          </tr>
	      <tr>
	        <td width="10" bgcolor="#FFFFFF">&nbsp;</td>
	        <td width="80" rowspan="2" valign="top" bgcolor="#FFFFFF"><div align="center"><a href="Cuisines/estonia.php"><img src="Images/32_Percent/Estonia.png" border="0" width="80" height="80" title="Click Here For More" alt="Estonian" /></a></div></td>
	        <td width="10" bgcolor="#FFFFFF">&nbsp;</td>
	        <td width="300" bgcolor="#FFFFFF"><h3 align="left">Estonian</h3></td>
	        <td width="10" bgcolor="#FFFFFF">&nbsp;</td>
	        <td width="10" bgcolor="#999999">&nbsp;</td>
	        <td width="10" bgcolor="#FFFFFF">&nbsp;</td>
	        <td width="80" rowspan="2" valign="top" bgcolor="#FFFFFF"><div align="center"><a href="Cuisines/lithiuania.php"><img src="Images/32_Percent/Lituania.png" border="0" width="80" height="80" title="Click Here For More" alt="Lithuanian" /></a></div></td>
	        <td width="10" bgcolor="#FFFFFF">&nbsp;</td>
	        <td width="300" bgcolor="#FFFFFF"><div align="left">
	          <h3>Lithiuanian</h3>
	        </div></td>
	        <td width="10" bgcolor="#FFFFFF">&nbsp;</td>
          </tr>
	      <tr>
	        <td width="10" bgcolor="#FFFFFF">&nbsp;</td>
	        <td width="10" bgcolor="#FFFFFF">&nbsp;</td>
	        <td width="300" valign="top" bgcolor="#FFFFFF"><div align="left">
			<p class="Place">Traditional <strong>Estonian cuisine</strong> has substantially been based on meat and potatoes, and on fish in coastal and lakeside areas, but is influenced by many other cuisines by now. In the present day, it includes a variety of international foods and dishes, with a number of contributions from the traditions of nearby countries. Scandinavian, German, Russian and other influences have played their part. The most typical foods in Estonia have been rye bread, pork, potatoes and dairy products. 
	          </p>
	          <p class="Place">Soups are traditionally eaten before the main course and most often are made of meat or chicken stock mixed with a variety of vegetables. Soups are also blended with sour cream, milk and yogurt. A very specific type of Estonian soup is <em>leivasupp</em>, which is a type of sweet soup that is made of black bread and apples, normally served with sour cream or whipped cream, often seasoned with cinnamon and sugar.
	          </p>	          
	          <p class="Place">Pork and potatoes accompanied by a rich gravy and often served with sauerkraut or other vegetables has been the traditional Estonian main course. Pork has been the most important meat and is eaten roasted, cured as bacon, in the form of ham, or in pies and sausages. There are many other main dishes too. </p>
	          <p class="Place">Black rye bread accompanies almost every savory food in Estonia. Instead of wishing &quot;bon appetit&quot;, Estonians are prone to say <em>jätku leiba</em> (&quot;may your bread last&quot;). Estonians continue to value their varieties of black rye-based bread. Estonia has not been a land of plenty. If a piece of bread was dropped on the floor, it was good form to pick it up, kiss it to show respect, and eat it. When Estonians live abroad, they often say that they miss black bread the most.</p></td>
	        <td width="10" bgcolor="#FFFFFF">&nbsp;</td>
	        <td width="10" bgcolor="#999999">&nbsp;</td>
	        <td width="10" bgcolor="#FFFFFF">&nbsp;</td>
	        <td width="10" bgcolor="#FFFFFF">&nbsp;</td>
	        <td width="300" valign="top" bgcolor="#FFFFFF"><div align="left">
	          <p class="Place">Lithuanian cuisine is pretty simple but has a variety of interesting dishes. Rye, potatoes, various meat, beet root, mushrooms and diary products are often used when preparing Lithuanian food. Because of their common heritage, Lithuanians, Poles, and Ashkenazi Jews share many dishes and beverages. Thus there are similar Lithuanian, Litvak, and Polish versions of dumplings (<em>koldunai</em>, kreplach or pierogi), doughnuts <em>spurgos</em> or (paczki), and <em>blynai</em> crepes (blintzes). German traditions also influenced Lithuanian cuisine, introducing pork and potato dishes, such as potato pudding (<em>kugelis</em> or kugel) and potato sausages (<em>vedarai</em>), as well as the baroque tree cake known as <em>Šakotis</em>. The most exotic of all the influences is Eastern (Karaite) cuisine, and the dishes <em>kibinai</em> and <em>ceburekai</em> are popular in Lithuania. Torte Napoleon was introduced during Napoleon"'"s passage through Lithuania.</p>
	        </div></td>
	        <td width="10" bgcolor="#FFFFFF">&nbsp;</td>
          </tr>
	      <tr>
	        <td width="10" bgcolor="#FFFFFF">&nbsp;</td>
	        <td width="80" bgcolor="#FFFFFF">&nbsp;</td>
	        <td width="10" bgcolor="#FFFFFF">&nbsp;</td>
	        <td width="300" bgcolor="#FFFFFF">&nbsp;</td>
	        <td width="10" bgcolor="#FFFFFF">&nbsp;</td>
	        <td width="10" bgcolor="#999999">&nbsp;</td>
	        <td width="10" bgcolor="#FFFFFF">&nbsp;</td>
	        <td width="80" bgcolor="#FFFFFF">&nbsp;</td>
	        <td width="10" bgcolor="#FFFFFF">&nbsp;</td>
	        <td width="300" bgcolor="#FFFFFF">&nbsp;</td>
	        <td width="10" bgcolor="#FFFFFF">&nbsp;</td>
          </tr>
	      <tr>
	        <td width="10" bgcolor="#FFFFFF">&nbsp;</td>
	        <td width="80" rowspan="2" valign="top" bgcolor="#FFFFFF"><div align="center"><a href="Cuisines/latvia.php"><img src="Images/32_Percent/Latvia.png" border="0" width="80" height="80" title="Click Here For More" alt="Latvian" /></a></div></td>
	        <td width="10" bgcolor="#FFFFFF">&nbsp;</td>
	        <td width="300" bgcolor="#FFFFFF"><h3 align="left">Latvian</h3></td>
	        <td width="10" bgcolor="#FFFFFF">&nbsp;</td>
	        <td width="10" bgcolor="#999999">&nbsp;</td>
	        <td width="10" bgcolor="#FFFFFF">&nbsp;</td>
	        <td width="80" bgcolor="#FFFFFF">&nbsp;</td>
	        <td width="10" bgcolor="#FFFFFF">&nbsp;</td>
	        <td width="300" bgcolor="#FFFFFF">&nbsp;</td>
	        <td width="10" bgcolor="#FFFFFF">&nbsp;</td>
          </tr>
	      <tr>
	        <td width="10" bgcolor="#FFFFFF">&nbsp;</td>
	        <td width="10" bgcolor="#FFFFFF">&nbsp;</td>
	        <td width="300" valign="top" bgcolor="#FFFFFF"><div align="left">
	          <p class="Place">Latvian cuisine typically consists of agricultural products, with meat featuring in most main meal dishes. Fish is commonly consumed due to Latvia"'"s location on the east coast of the Baltic Sea.          Latvian cuisine has been influenced by neighboring countries in the Baltic region. Common ingredients in Latvian recipes are found locally, such as potatoes, wheat, barley, cabbage, onions, eggs and pork. Latvian food is generally quite fatty, and uses few spices.</p>
	        </div>
            <div align="left"></div></td>
	        <td width="10" bgcolor="#FFFFFF">&nbsp;</td>
	        <td width="10" bgcolor="#999999">&nbsp;</td>
	        <td width="10" bgcolor="#FFFFFF">&nbsp;</td>
	        <td width="80" bgcolor="#FFFFFF">&nbsp;</td>
	        <td width="10" bgcolor="#FFFFFF">&nbsp;</td>
	        <td width="300" bgcolor="#FFFFFF">&nbsp;</td>
	        <td width="10" bgcolor="#FFFFFF">&nbsp;</td>
          </tr>
	      <tr>
	        <td width="10" bgcolor="#FFFFFF">&nbsp;</td>
	        <td width="80" bgcolor="#FFFFFF">&nbsp;</td>
	        <td width="10" bgcolor="#FFFFFF">&nbsp;</td>
	        <td width="300" bgcolor="#FFFFFF">&nbsp;</td>
	        <td width="10" bgcolor="#FFFFFF">&nbsp;</td>
	        <td width="10" bgcolor="#FFFFFF">&nbsp;</td>
	        <td width="10" bgcolor="#FFFFFF">&nbsp;</td>
	        <td width="80" bgcolor="#FFFFFF">&nbsp;</td>
	        <td width="10" bgcolor="#FFFFFF">&nbsp;</td>
	        <td width="300" bgcolor="#FFFFFF">&nbsp;</td>
	        <td width="10" bgcolor="#FFFFFF">&nbsp;</td>
  </tr>
</table>
EOD;
echo $html;
?>

Open in new window

0
 
Dave BaldwinFixer of ProblemsCommented:
It's not the PHP that is doing that.  What you posted works fine in a page by itself.  But you are loading it thru AJAX and apparently that's where it's having a problem.  Try encoding the single quotes as &#039; .  That will cause the browser to display the single quote or apostrophe and may get it to pass thru your AJAX.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
DS928Author Commented:
Yes, this works.  However in Dreamweaver CS6 it now turns all text after it yellow instead of red.  What does that mean?
0
 
Dave BaldwinFixer of ProblemsCommented:
I have no idea, I don't use Dreamweaver.  Does it display properly in a real browser?
0
 
DS928Author Commented:
Yes it does.  I'm trying to find out why......still looking.
0
 
Dave BaldwinFixer of ProblemsCommented:
Thanks for the points.  It's probably Dreamweaver 'helping' you.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now