Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Apostrophe in HERDOC

Posted on 2013-05-14
7
Medium Priority
?
174 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 84

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 84

Accepted Solution

by:
Dave Baldwin earned 2000 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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 84

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 84

Expert Comment

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

Featured Post

Technology Partners: 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!

Question has a verified solution.

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

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…

670 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