Jump to content

[SOLVED] Help with double quotes issue


jwhite68

Recommended Posts

I have a string thats displayed from a database table, and when the database value contains a string in quotes, its not displayed in the output form.

 

So if the value of advtitle is  - this is an advert, as "featured on tv"

 

When displayed it shows - this is an advert, as

 

So its missing the "featured on tv" part.

 

Here is the code:

 

					<tr>
						<td class="td135" style="text-align:right !important"><span<?=$hlight4?>>Ad title</span></td>
						<td colspan="5" class="td675"><input type="text" name="advtitle" maxlength="128" value="<?=$advtitle?>" style="width:385px"></td>
					</tr>

 

Can anyone advise what I need to do in PHP to the <=?advtitle?> code. I tried addslashes but that didnt work.

 

Link to comment
Share on other sites

Try using a single double quote and see if the query gives an error.

If it does, you forgot to escape your double quotes.

 

Since your query is probably written in double quotes, it causes an error as it gets all messy.

 

You can either use addslashes($_POST["YOUR_FORM_ITEM"]); or htmlspecialchars($_POST["YOUR_FORM_ITEM"], ENT_QUOTES);.

 

Add slashes will simply add a \ to the " which will tell PHP to see it as a character instead of a double quote and the latter will change the doublequote into its HTML code (&#039;), you can use html_entity_decode to bring it back if needed.

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.