Solved

Apostrophe in HERDOC

Posted on 2013-05-14
7
173 Views
Last Modified: 2013-05-14
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
Comment
Question by:DS928
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39166940
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
 

Author Comment

by:DS928
ID: 39166990
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
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 39167085
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!

 

Author Comment

by:DS928
ID: 39167101
Yes, this works.  However in Dreamweaver CS6 it now turns all text after it yellow instead of red.  What does that mean?
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39167111
I have no idea, I don't use Dreamweaver.  Does it display properly in a real browser?
0
 

Author Comment

by:DS928
ID: 39167114
Yes it does.  I'm trying to find out why......still looking.
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39167119
Thanks for the points.  It's probably Dreamweaver 'helping' you.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question