Jump to content

Single quotes issue in Google Chrome


Ivan Ivković

Recommended Posts

I'm not sure if this is an HTML or browser issue...

But single quotes in strings from database don't work for me in Chrome for some reason. To mine or any other computers.

Every other browser detects these quotes.

 

I'm outputting an SQL result containing strings like:

 

Texas Hold'em

or

America's Cup

 

and I get

 

Texas Hold

America

Link to comment
Share on other sites

The problem is not with Chrome - it is with the code. It just seems that FF is correcting the error - something you should not be relying on.

 

I didn't check all of your code, but I found this one line that would cause problems

<option label='People's Democratic Republic of Yemen' value='YD'>People's Democratic Republic of Yemen</option>

 

You use single quotes to enclose the value for the label parameter. But, that value ALSO has a single quote mark in it. You could do several things:

 

1. Use double quotes (as long as no values use double quotes)

2. Use addslashes()

3. Use htmlspecialchars()

Link to comment
Share on other sites

if you use htmlentities($string, ENT_QUOTES) for the fields that may have quotes in them, it should clear that up.

 

as psycho mentioned, the problem is you have this for example:

label='Texas Hold'em Bonus Poker'

 

the above function would change it to:

label='Texas Hold&#39;em Bonus Poker'

 

which would show up in the browser how you want it

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.