Jump to content

[SOLVED] Questions about problems with quotes and echos


Chappers

Recommended Posts

Hi,

 

Having some problems regarding quotes. I'm taking an entry from the MySQL table in the format 5'11" (as in five feet eleven inches). This is my variable $height.

 

$height = $row['height'];

 

Then I place it in a form which can be edited, which is inside an echo container:

 

echo "
<td><span class=\"n\">Height:</span></td>
<td><input class=\"n2\" type=\"text\" name=\"height\" maxlength=\"100\" value=\"$height\"></td>
";

 

Which displays the height without the quote mark for inches, i.e. 5'11

 

So I thought I'd try a replace:

 

$height = $row['height'];
$height2 = str_replace('"','\"',$height);

 

But that just outputs: 5'11\

 

What's the usual way around this, considering that the height variable contains both single and double quote marks?

 

I know one can use echo ?> then the HTML and add variables with <?php echo $height ?> so double quotes are still usable, but since the elements use quotes as delimiters, like value="height", how can another double quote be added in there without it thinking it's the delimiter. There must be a way around this? I found one webpage that stated putting two single quotes will output just one when entering the information into a MySQL database, but that's as far as I got with help on the net.

 

Thank you to any and all who take this question on.

 

James

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.