switchdoc Posted August 21, 2006 Share Posted August 21, 2006 Hello all!Hoping you can help me with what is probably a simple issue but it has me stymied.I am working with google maps and ajax and I have to take a fairly complex bit of info and stuff it into one variable. Here it is:echo "var point = new GLatLng(" . $location . ");";echo "var marker = createMarker(point,\"$name\",'<div id=\"infowindow\" style=\"white-space: nowrap;\">" . addslashes($row['name']) . $spacer . addslashes($row['address']) . $spacer . addslashes($row['city']) . $comma . $space . addslashes($row['state']) . $spacer . addslashes($row['zipcode']) . $doublespacer . addslashes($row['description']) . "</div>');\n";echo "map.addOverlay(marker);\n";echo "\n";I need to get $info to equal all of that so it can be passed correctly back to my script.I am having a terrible time getting all the characters escaped. The semi-colons in particular resist all my efforts. Its got to be simple, but i can't seem to get it. How can I get $info = "<all that stuff>";?Thanks in advance!-Switchdoc Quote Link to comment https://forums.phpfreaks.com/topic/18152-help-with-echo/ Share on other sites More sharing options...
ToonMariner Posted August 21, 2006 Share Posted August 21, 2006 not exactly sure what you are after BUT if $info has to contain the entire string that you generate (i.e. var point = ....) just do this....$info = "var point = new GLatLng(" . $location . ");";$info .= "var marker = createMarker(point,\"$name\",'<div id=\"infowindow\" style=\"white-space: nowrap;\">" . addslashes($row['name']) . $spacer . addslashes($row['address']) . $spacer . addslashes($row['city']) . $comma . $space . addslashes($row['state']) . $spacer . addslashes($row['zipcode']) . $doublespacer . addslashes($row['description']) . "</div>');\n";$info .= "map.addOverlay(marker);\n";$info .= "\n";echo $info;now you have all that in info and can passs it anywhere you like. Quote Link to comment https://forums.phpfreaks.com/topic/18152-help-with-echo/#findComment-77953 Share on other sites More sharing options...
switchdoc Posted August 21, 2006 Author Share Posted August 21, 2006 Thanks for the reply! It's close but I am still running into an issue.Here is what I am running into:Here is an example of what I ultimately need outputted with all the variables added so its easier to see whats going on:[quote]var point = new GLatLng(39.925512 , -105.086708);var marker = createMarker(point,"Broomfield Location",'<div id="infowindow" style="white-space: nowrap;">Broomfield location<br>123 W smith<br>Broomfield, CO<br>80020<br><br>Email:<br>[email protected]</div>');map.addOverlay(marker);[/quote]Here is what I am getting with the example you provided:[quote]var point = new GLatLng(39.925512 , -105.086708);var marker = createMarker(point,"Broomfield Location",'Broomfield location123 W smithBroomfield, CO80020Email:[email protected]'); map.addOverlay(marker); [/quote]The <div .....> and </div> tags are gone. Is there a way to escape this so those stay? Its gotta be easy but I've thrown every \ at it I can think of and nothing :)Thanks,-Switch Quote Link to comment https://forums.phpfreaks.com/topic/18152-help-with-echo/#findComment-78153 Share on other sites More sharing options...
willpower Posted August 21, 2006 Share Posted August 21, 2006 here the ' and the " are both escaping the string to be addedso the '<div..... is being escaped at 'so it should become$info = "var point = new GLatLng(" . $location . ");";$info .= "var marker = createMarker(point,\"$name\",\'<div etc.... Quote Link to comment https://forums.phpfreaks.com/topic/18152-help-with-echo/#findComment-78160 Share on other sites More sharing options...
switchdoc Posted August 21, 2006 Author Share Posted August 21, 2006 I appreciate the reponse!I've added the slash where indicated, but no joy. Now I just get:[quote]var point = new GLatLng(39.922512 , -105.087608);var marker = createMarker(point,"Broomfield Location",\'Broomfield Location123 w smithBroomfield, CO80020Email:[email protected]'); map.addOverlay(marker); [/quote]Basically it just shows the slash.. this kind of little stuff drives me nuts. Quote Link to comment https://forums.phpfreaks.com/topic/18152-help-with-echo/#findComment-78164 Share on other sites More sharing options...
jsimmons Posted August 21, 2006 Share Posted August 21, 2006 </div>'should be</div>\' Quote Link to comment https://forums.phpfreaks.com/topic/18152-help-with-echo/#findComment-78180 Share on other sites More sharing options...
switchdoc Posted August 21, 2006 Author Share Posted August 21, 2006 Again thanks for the reply.Added the changes suggested by folks so far. Here again is the code:[code]$ssInfo = "var point = new GLatLng(" . $location . ");";$ssInfo .= "var marker = createMarker(point,\"$name\",\'<div id=\"infowindow\" style=\"white-space: nowrap;\">" . addslashes($row['name']) . $spacer . addslashes($row['address']) . $spacer . addslashes($row['city']) . $comma . $space . addslashes($row['state']) . $spacer . addslashes($row['zipcode']) . $doublespacer . addslashes($row['description']) . "</div>\');\n";$ssInfo .= "map.addOverlay(marker);\n";$ssInfo .= "\n";[/code]And here is the result:[quote]var point = new GLatLng(39.925112 , -105.087608);var marker = createMarker(point,"Broomfield Location",\'Broomfield Location123 w smithBroomfield, CO80020Email:[email protected]'); map.addOverlay(marker); [/quote]Still no div :(Any other thoughts? Quote Link to comment https://forums.phpfreaks.com/topic/18152-help-with-echo/#findComment-78188 Share on other sites More sharing options...
switchdoc Posted August 22, 2006 Author Share Posted August 22, 2006 *bump* Quote Link to comment https://forums.phpfreaks.com/topic/18152-help-with-echo/#findComment-78356 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.