Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7507995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:35:53+00:00 2026-05-29T22:35:53+00:00

I query my mySql database table and retrieve text strings that look like this:

  • 0

I query my mySql database table and retrieve text strings that look like this:

  This is a piece of a bronze artifact from the 'Bronze Age' -- it's in outstanding shape.
  His amusing comment on the 3rd-century clay bowl:  "Wow, she's a real piece!"
  It's no secret that you 'don't mishandle old parchment artifacts, they're "very" fragile' -- yet it still happens.

THE PROBLEM — I use php variables to hold the above strings read from the database, and use the PHP variables in my heredoc form. And I saw right away that a string got truncated when the first space in the string was encountered — the form only showed text up to the first space.

So I put single quotes around my PHP variables in the heredoc form (see below).

Now I get truncation when the string that came from the database has single quotes.

I can put quotes around my php variables but I’m getting truncations of the text strings when single quotes, double quotes
and if I don’t quote the PHP variable in the heredoc — a space in the string truncates the string from that point on.

I’m using PHP and here is the code that gets data from the mySql query result, stores the database data into PHP variables, then uses them in a heredoc:

   $row = mysql_fetch_row($result);
   //var_dump($row);  // the dump proves that the full string comes 
                      // out of the database, with spaces, single and double quotes

   $descriptionOfArtifact = $row[0];
   $commentsAboutTheDiggingSite = $row[1];
   $expertRecommendationsForRestoring = $row[2];

     // output the next row from the Artifacts table...
       echo <<< NEXT_ROW_HEREDOC
         <input type="text" id="Description"   
             name="descrip" value='$descriptionOfArtifact' readonly="readonly"></input>     
         <input type="text" id="Comments"       
             name="comments" value='$commentsAboutTheDiggingSite' readonly="readonly"></input>    
         <input type="text" id="Experts"
              name="experts" value='$expertRecommendationsForRestoring' readonly="readonly"></input>    
   NEXT_ROW_HEREDOC;

I need this form to display the full text string that is read from the database and stored in the above PHP variables. I thought the single quotes around the variable names would do it but I think the heredoc is messing that up (somehow).

So in a heredoc, how can I use PHP variables and be able to see:

  • single quotes
  • double quotes
  • spaces
  • html tags
  • any printable character, really

in a heredoc form?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T22:35:54+00:00Added an answer on May 29, 2026 at 10:35 pm

    You have a space between the <<< and the end-of-text keyword. That’s probably causing the issue.

    Also, call htmlspecialchars on $row[0], $row[1] and $row[2] when you’re assigning them to variables, and use double-quotes on your value="..." attribute.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm reading data from a table( from a MySQL Database) with Hibernate SQL Query.
I'm trying to create a simple database table using the PHP MySQL query Create
Is there a way to query a MySQL database that gives me all blobs
I need to run a RLIKE query on a database mmoved from MySQL to
I was using the following code to retrieve HTML snippets from a database table
I have table with checkboxes, which I retrieve from database : <?php $result =
I am trying to figure out how to retrieve data from a MySQL database
I need a help constructung an sql query for mysql database. 2 Table as
i am trying to select information from my mysql database with this statement after
Whats this?? my query is: Doctrine_Query::create() ->select('rec.*') ->from('Records rec') ->execute(); Records table contains more

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.