Sie sind nicht angemeldet.

Douglas Rhiner

Fortgeschrittener

  • »Douglas Rhiner« ist der Autor dieses Themas

Beiträge: 141

Wohnort: San Anselmo, CA

Beruf: Code-Slave

  • Nachricht senden

1

Donnerstag, 29. September 2011, 20:09

Apostrophe, XML and JS call escaping

Got an Apostrophe issue.
My XML is generated via PHP and MySQL queries.

I have the following to create the beginning scene tag......

echo "<scene name=\"" . $index . "\" title=\"" . $name . "\" onstart=\"set(hotspot.enabled,true); js(myfunction(" . $name . ",$lat,$long)); ";

My issue is that I have two uses of the variable $name; one that sets the "title" of the scene and one that is used in a JS call.
When an apostrophe is used in the text associated with $name all heck breaks loose.
Otherwise everything is perfect.

I've tried escaping the variable $name in two formats; %27 for the JS call ( as one would for tooltips ) and ' for the XML "title".....
  1. $namejs = str_replace("'","%27",$name);
  2. $namexml = str_replace("'","'",$name);

....where $namejs is used for the JS call and $namexml is used to set the "title".


This does not seem to work. Or I've missed something.

The above method of str_replace() works just fine for escaping the text for tooltips:

$tooltip1 = $row1['tooltip'];
$tooltip = str_replace("'","%27",$tooltip1);

Been fiddling with this for a bit now and am somewhat stumped. *confused*


Any ideas?

Beiträge: 1 857

Beruf: Virtual Tours - Photography - Krpano developer

  • Nachricht senden

2

Donnerstag, 29. September 2011, 23:06

Try the ones for here. http://www.w3schools.com/tags/ref_entities.asp
And if that dog dont hunt let me know and ill see what im actually using when i return to the office.
KRPano Developer: Portfolio ::Gigapixel Tagging Solutions - Porfolio 2 :: Facebook :: Twitter :: reddit.com/r/VirtualTour