/    Sign up×
Community /Pin to ProfileBookmark

problem. blank screen

something is wrong here… formatting i think a ” or some **** but i’ve spent hours going over this time and time agian its gonna smack me in the damn face i know it… but can someone point out what the hell i’ve done wrong???

my code

[CODE]<?php
session_start();

$froma = $_SESSION[‘froma’];
$dropoff = $_SESSION[‘dropoff’];

unset($_SESSION[‘froma’]);

unset($_SESSION[‘dropoff’]);
session_destroy();

print(“<html><head>”);
print(“<script src=”http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAKBQCMjjfKSlhfW56Px_BxhSkc0RhBuv0oL0fIKsBsOMFMKMHUBSTswp2ETs99XXTFGeCud1cJwVTtg” type=”text/javascript”></script>”);
print(“<script type=”text/javascript”>”);
print(“var map;”);
print(“var gdir;”);
print(“var geocoder = null;”);
print(“var addressMarker;”);
print(“function initialize() {“);
print(“if (GBrowserIsCompatible()) {“);
print(“map = new GMap2(document.getElementById(“map_canvas”));”);
print(“gdir = new GDirections(map, document.getElementById(“directions”));”);
print(“GEvent.addListener(gdir, “load”, onGDirectionsLoad);”);
print(“GEvent.addListener(gdir, “error”, handleErrors);”);
print(“map.setCenter(new GLatLng(35.595344, -80.906754), 10);”);
print(“}”);
print(“}”);
print(“function setDirections(fromAddress, toAddress) {“);
print(“gdir.load(“from: ” + $froma + ” to: ” + $dropoff);”);
print(“}”);
print(“function onGDirectionsLoad(){ var passengers = document.formfares.Passengers.value;”);
print(“var miles = gdir.getDistance().meters/1609.344;”);
print(“var fifthmiles = Math.ceil(miles/.2);”);
print(“var persons = 0;”);
print(“var fare = 0;”);
print(“if(passengers > 2) {persons = (passengers – 2) * 2};”);
print(“fare = 2.0 + (fifthmiles * .4) + persons;”);
print(“document.getElementById(“output”).innerHTML = “Your estimated taxi fare is: $”+fare.toFixed(2);”);
print(“}”);
print(“function handleErrors(){“);
print(“if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)”);
print(“alert(“No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.nError code: ” + gdir.getStatus().code);”);
print(“else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)”);
print(“alert(“A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.n Error code: ” + gdir.getStatus().code);”);
print(“else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)”);
print(“alert(“The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.n Error code: ” + gdir.getStatus().code);”);
print(“else if (gdir.getStatus().code == G_GEO_BAD_KEY)”);
print(“alert(“The given key is either invalid or does not match the domain for which it was given. n Error code: ” + gdir.getStatus().code);”);
print(“else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)”);
print(“alert(“A directions request could not be successfully parsed.n Error code: ” + gdir.getStatus().code);”);
print(“else alert(“An unknown error occurred.”);”);
print(“}”);
print(“</script>”);
print(“</head>”);
print(“<body onload=”initialize() ; setDirections() ;”>”);
print(“<div id=”output” style=”width: 250px; height: 30px; font-size:15px”></div>”);
print(“<div id=”map_canvas” style=”width: 0px; height: 0px; POSITION:ABSOLUTE; TOP:0PX;LEFT:0PX;” align=”center”></div>”);
print(“</body>”);
print(“</html>”);
?>
[/CODE]

the dom source from browser..

[CODE]<html><head><script src=”http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAKBQCMjjfKSlhfW56Px_BxhSkc0RhBuv0oL0fIKsBsOMFMKMHUBSTswp2ETs99XXTFGeCud1cJwVTtg” type=”text/javascript”></script><script type=”text/javascript”>var map;var gdir;var geocoder = null;var addressMarker;function initialize() {if (GBrowserIsCompatible()) {map = new GMap2(document.getElementById(“map_canvas”));gdir = new GDirections(map, document.getElementById(“directions”));GEvent.addListener(gdir, “load”, onGDirectionsLoad);GEvent.addListener(gdir, “error”, handleErrors);map.setCenter(new GLatLng(35.595344, -80.906754), 10);}}function setDirections(fromAddress, toAddress) {gdir.load(“from: ” + + ” to: ” + );}function onGDirectionsLoad(){ var passengers = document.formfares.Passengers.value;var miles = gdir.getDistance().meters/1609.344;var fifthmiles = Math.ceil(miles/.2);var persons = 0;var fare = 0;if(passengers > 2) {persons = (passengers – 2) * 2};fare = 2.0 + (fifthmiles * .4) + persons;document.getElementById(“output”).innerHTML = “Your estimated taxi fare is: $”+fare.toFixed(2);}function handleErrors(){if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)alert(“No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.
Error code: ” + gdir.getStatus().code);else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)alert(“A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.
Error code: ” + gdir.getStatus().code);else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)alert(“The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.
Error code: ” + gdir.getStatus().code);else if (gdir.getStatus().code == G_GEO_BAD_KEY)alert(“The given key is either invalid or does not match the domain for which it was given.
Error code: ” + gdir.getStatus().code);else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)alert(“A directions request could not be successfully parsed.
Error code: ” + gdir.getStatus().code);else alert(“An unknown error occurred.”);}</script></head><body onload=”initialize() ; setDirections() ;”><div id=”output” style=”width: 250px; height: 30px; font-size:15px”></div><div id=”map_canvas” style=”width: 0px; height: 0px; POSITION:ABSOLUTE; TOP:0PX;LEFT:0PX;” align=”center”></div>
print(“hello world”);
</body></html>[/CODE]

but nothing is being displayed on the page at all

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@OctoberWindOct 28.2009 — first of all, why are you trying to <?php print (" "); ?> all those lines of js? Why not close the PHP block, and just write the js?

second, when I try that, I get this error:
This web site needs a different Google Maps API key.
A new key can be generated at http://code.google.com/apis/maps/.


which is the same thing I get when I try and run the first script (http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAKBQCMjjfKSlhfW56Px_BxhSkc0RhBuv0oL0fIKsBsOMFMKMHUBSTswp2ETs99XXTFGeCud1cJwVTtg) which is probably why the second script isn't running because the variables its looking for (map, gdir, addressMarker) are not found.
Copy linkTweet thisAlerts:
@filespaceauthorOct 28.2009 — there is not anything wrong with my java script..you get that error because the api key i posted belongs to me and my domain and you dont have access to use that api with out your own api key....


closing the php block didnt seem to work for me.. as i was not able to get my $froma and $dropoff variables into the javascript... im still playing been attacking this issue all damn night.. script works just fine but i gotta get some info outta my stored session var...
Copy linkTweet thisAlerts:
@allanice001Oct 28.2009 — shouldn't wait till the end of the form before you do this?

<code

unset($_SESSION['froma']);

unset($_SESSION['dropoff']);

session_destroy();

</code>
×

Success!

Help @filespace spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.1,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...