Jump to content

[SOLVED] display field from database with a quote in a textbox


Recommended Posts

Hi

 

I am selecting a field sponsorname from a mysql table.  The sponsor name is Johny's sponsor.

 

I then want to display it in a textbox field for update.  Below are the relevant lines of code.  The code below works fine for a sponsor name of  jan v/d merwe, but doesn't work for johny's.

 

$sponsorresult = mysql_query(
		  'SELECT sponsorname from sponsor WHERE ....');

list($sponsorname) = mysql_fetch_array($sponsorresult);

$defaults['sponsorname'] = htmlentities($sponsorname);

.
.
  <p class="bigtext">Sponsor Name<br/><input type="text" name="sponsorname" maxlength="30" value='<?php echo $defaults['sponsorname'] ?>'/>


 

it doesn't display anything after the '

Hi andibakker,

 

Have a look at the htmlentities manual here http://us3.php.net/manual/en/function.htmlentities.php, in particular the 'quote_style' parameter.

 

Change the following line of code to read:

 

$defaults['sponsorname'] = htmlentities($sponsorname, ENT_QUOTES);

 

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.