Solved

Apostrophe in HERDOC

Posted on 2013-05-14
7
162 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
  • 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SVG Logo 4 33
Basic JavaScript Question 3 38
Show banners that are blocked by Ad Muncher 10 46
send keys not working in vba 7 38
Introduction The Google Maps API offers various ways to draw dynamic and static maps.  Using a combination of PHP and JavaScript, you can draw active JavaScript maps that allow pan-and-zoom in the client browser window.  You can also draw "static" …
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.
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…

911 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now