Jump to content

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


andibakker

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);

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.