0

I have a piece of code which is driving me crazy please help!

Basically I have result set from a database returning 3 rows of data, the data in the field I'm interested in is as below:

row 1 - "the Retention Release Date;"
row 2 - "where applicable, any later due date for Retention release under clause 4·15·2·3; or"
row 3 - "the date of issue of the Contractor's statement under clause 4·6·2 or, in default, the last date for issue of that statement."

The array is $result_set and the associative key is ['subsubclausedesc'] so the code I am running is:

while($result_set = $database->fetch_array($result)) 
{
    echo htmlentities($result_set['subsubclausedesc']);
}

The problem I am having is that only the 1st row is being returned to the screen, if I echo without htmlentities I get all 3 rows, what am I doing wrong?

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Dave Whitwell
  • 81
  • 1
  • 8
  • Try `htmlentities($result_set['subsubclausedesc'], ENT_QUOTES, "utf-8");` and see if it makes any difference. Also, make sure that you've set UTF-8 as the charset on your page using `` in your head. – Wayne Whitty Nov 08 '13 at 11:09
  • use mysql_real_escape_string – Zahidul Hossein Ripon Nov 08 '13 at 11:10
  • @ZahidulHosseinRipon mysql_real_escape_string is only used on input, not output. – Wayne Whitty Nov 08 '13 at 11:12
  • Wayne thanks for the response but still doesn't work, my page head does include the I am wondering if this is some kind of setting in the php.ini file, as I had this running on wamp on a local machine, now trying on a server running IIS8 and ran into the problem. – Dave Whitwell Nov 08 '13 at 11:26
  • Zahidul the database I am using is sql server so I do not believe using mysql_real_escape_string would work? – Dave Whitwell Nov 08 '13 at 11:26
  • Okay I have now discovered that it is the middle dot · that is causing the problem, although I do not understand why this is the case, any ideas? – Dave Whitwell Nov 08 '13 at 14:43
  • Found the answer in http://stackoverflow.com/questions/15007956/html-entities-not-converting-special-characters For some reason you need to use utf8_encode prior to htmlentities. – Dave Whitwell Nov 08 '13 at 15:02

1 Answers1

0

You can try this with stripslashes

  while($result_set = $database->fetch_array($result)) 
    {
    echo htmlentities(stripslashes($result_set['subsubclausedesc']));
    }
Nagarajbgk
  • 31
  • 1