?
Solved

Error "Missing Before Statement"

Posted on 2006-06-02
12
Medium Priority
?
327 Views
Last Modified: 2011-09-20
Hi all,
I getting the following error when I try to run this on my localhost apache server. Its strange because it works one my web-server alright. Any help would be greatly appreciated.
Thanks,
D



Error: missing ; before statement
Source File: http://localhost/reacha_website/map/subfindertester.php
Line: 50, Column: 3
Source Code:
line 50: no result

Here's the page source from the browser:
<html>
<head>
<title>SubFinder</title>

<script src="http://maps.google.com/maps?file=api&v=1&key=ABQIAAAAz2q3fh2p6GN4ORUIygGqvRQTA871Al9LlI3HaXbjlStHkuM96hSyzJwDNWLXAvPS7jgmNUkevgdoNg " type="text/javascript"></script>

</head>
<body>
<p><strong>SubFinder</strong></p>

<div id="map" style="width: 800px; height: 600px"></div>


<script type="text/javascript">
//<![CDATA[

var baseIcon = new GIcon();
baseIcon.shadow = "http://www.reachateacher.ie/map/img/shadow50.png";
baseIcon.iconSize = new GSize(20, 34);
baseIcon.shadowSize = new GSize(37, 34);
baseIcon.iconAnchor = new GPoint(9, 34);
baseIcon.infoWindowAnchor = new GPoint(9, 2);
baseIcon.infoShadowAnchor = new GPoint(18, 25);

// Creates a marker whose info window displays the given number
function createMarker(point, text, markerstyle)
{
var icon = new GIcon(baseIcon);
icon.image = "http://www.reachateacher.ie/map/img/Marker" + markerstyle + ".png";
var marker = new GMarker(point, icon);
// Show this markers index in the info window when it is clicked
var html = text;
GEvent.addListener(marker, "click", function() {marker.openInfoWindowHtml(html);});
return marker;
};




var map = new GMap(document.getElementById("map"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.addControl(new GScaleControl());
map.centerAndZoom(new GPoint(0, 0), 16);





no result
GEvent.addListener(map, 'click', function(overlay, point) {
if (overlay) {
//map.removeOverlay(overlay);
} else if (point) {

output.innerHTML = "<form name=form1 method=post action=subfinder_load_db.php><table border=0>"+
"<tr><td>Lat:</td><td align=left><input name=new_lat type=text id=new_lat value=" + point.y + "></td><td"+
"rowspan=4><input name=new_marker type=radio value=A checked>Active<br><input name=new_marker type=radio "+
"value=M>Museum<br><input name=new_marker type=radio value=S>Sunk<br><input name=new_marker type=radio value=E>Event</td></tr>"+
"<tr><td>Lon:</td><td align=left><input name=new_lon type=text id=new_lon value=" + point.x + "></td></tr>"+
"<tr><td>Text:</td><td align=left><input name=new_desc type=text id=new_desc size=60></td></tr>"+
"<tr><td>URL:</td><td align=left><input name=new_url type=text id=new_url size=60></td></tr>"+
"<tr></td><td align=left><input type=submit name=Submit value=Submit></td></tr></table></form>";

if (map.getZoomLevel() >= zoomToLevel) {
map.centerAndZoom(point, zoomToLevel);
}
map.addOverlay(new GMarker(point));
}
}
);
//]]>

</script>

<div id="output"></div>



0
Comment
Question by:dereksheahan
  • 7
  • 4
12 Comments
 
LVL 10

Expert Comment

by:ClickCentric
ID: 16819651
------------------------------------------------------------------

map.centerAndZoom(new GPoint(0, 0), 16);





no result
GEvent.addListener(map, 'click', function(overlay, point) {

-------------------------------------------------------------------

Is that 'no result' actually in the code?  If it is, that's a likely source.
0
 

Author Comment

by:dereksheahan
ID: 16819681
yes its in the code.
Here's the code for the page:
<html>
<head>
<title>SubFinder</title>

<script src="http://maps.google.com/maps?file=api&v=1&key=ABQIAAAAz2q3fh2p6GN4ORUIygGqvRQTA871Al9LlI3HaXbjlStHkuM96hSyzJwDNWLXAvPS7jgmNUkevgdoNg " type="text/javascript"></script>

</head>
<body>
<p><strong>SubFinder</strong></p>

<div id="map" style="width: 800px; height: 600px"></div>


<script type="text/javascript">
//<![CDATA[

var baseIcon = new GIcon();
baseIcon.shadow = "http://www.reachateacher.ie/map/img/shadow50.png";
baseIcon.iconSize = new GSize(20, 34);
baseIcon.shadowSize = new GSize(37, 34);
baseIcon.iconAnchor = new GPoint(9, 34);
baseIcon.infoWindowAnchor = new GPoint(9, 2);
baseIcon.infoShadowAnchor = new GPoint(18, 25);

// Creates a marker whose info window displays the given number
function createMarker(point, text, markerstyle)
{
var icon = new GIcon(baseIcon);
icon.image = "http://www.reachateacher.ie/map/img/Marker" + markerstyle + ".png";
var marker = new GMarker(point, icon);
// Show this markers index in the info window when it is clicked
var html = text;
GEvent.addListener(marker, "click", function() {marker.openInfoWindowHtml(html);});
return marker;
};




var map = new GMap(document.getElementById("map"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.addControl(new GScaleControl());
map.centerAndZoom(new GPoint(0, 0), 16);





<?php
include_once('../Connections/Map.php');

mysql_select_db($database_Map, $Map);
$result = mysql_query("SELECT * FROM subfinder",$map);
if (!$result)
{
echo "no result";
}

while($row = mysql_fetch_array($result))
{
if ($row['marker'] == 'A') $marker_type = 'Active';
if ($row['marker'] == 'M') $marker_type = 'Museum';
if ($row['marker'] == 'S') $marker_type = 'Sunk';
if ($row['marker'] == 'E') $marker_type = 'Event';
$info_text = "<div id=\"infowindow\" style=\"white-space: nowrap;\"><b>" . $marker_type . "</b><br>" . $row['desc'] . "<br><br><a href=" . $row[url] . " target=_blank>Link</a></div>";
echo "var point = new GPoint(" . $row['lon'] . "," . $row['lat'] . ");\n";
echo "var marker = createMarker(point, '" . $info_text . "','" . $row['marker'] . "');\n";
echo "map.addOverlay(marker);\n";
echo "\n";
}

mysql_close($Map);
?>

GEvent.addListener(map, 'click', function(overlay, point) {
if (overlay) {
//map.removeOverlay(overlay);
} else if (point) {

output.innerHTML = "<form name=form1 method=post action=subfinder_load_db.php><table border=0>"+
"<tr><td>Lat:</td><td align=left><input name=new_lat type=text id=new_lat value=" + point.y + "></td><td"+
"rowspan=4><input name=new_marker type=radio value=A checked>Active<br><input name=new_marker type=radio "+
"value=M>Museum<br><input name=new_marker type=radio value=S>Sunk<br><input name=new_marker type=radio value=E>Event</td></tr>"+
"<tr><td>Lon:</td><td align=left><input name=new_lon type=text id=new_lon value=" + point.x + "></td></tr>"+
"<tr><td>Text:</td><td align=left><input name=new_desc type=text id=new_desc size=60></td></tr>"+
"<tr><td>URL:</td><td align=left><input name=new_url type=text id=new_url size=60></td></tr>"+
"<tr></td><td align=left><input type=submit name=Submit value=Submit></td></tr></table></form>";

if (map.getZoomLevel() >= zoomToLevel) {
map.centerAndZoom(point, zoomToLevel);
}
map.addOverlay(new GMarker(point));
}
}
);
//]]>
</script>

<div id="output"></div>

0
 
LVL 10

Expert Comment

by:ClickCentric
ID: 16819770
Yeah, you can't have that 'no result' showing up in the middle of javascript.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 10

Expert Comment

by:ClickCentric
ID: 16819787
Every time there's no result, the script will fail because 'no result' means nothing in javascript and will throw an error.  Either wrap the whole thing around the php if or get rid of the echo "no result"; line.
0
 
LVL 10

Expert Comment

by:ClickCentric
ID: 16819792
That should be "either wrap the whole thing in the javascript if"  not "around"
0
 

Author Comment

by:dereksheahan
ID: 16819807
Hi ClickCentric,
Its strange because as I mentioned previously this page works fine on my web-server but doesn't work on my localhost apache server. As you can see from the above code the echo "no result" is include in a php statement and so I'm sure its okay to put it like that. No idea why its not working for me though?
Thanks,
D
0
 
LVL 10

Expert Comment

by:ClickCentric
ID: 16819809
My brain must be melting because that's not worded right either.  

Just forget that one and imagine this in it's place:

Every time there's no result, the script will fail because 'no result' means nothing in javascript and will throw an error.  Either wrap the whole thing in the php if statement or get rid of the echo "no result"; line.
0
 
LVL 10

Expert Comment

by:ClickCentric
ID: 16819818
Let me guess, on your webserver, there's a database with values and on your localhost apache server there isn't?  That's what's causing the "no result" line to be echoed.
0
 

Author Comment

by:dereksheahan
ID: 16819866
I know what you're saying alright. I've examined the php statement long and hard and it seems okay (ie it is linked to db on localhost) but your right, this is why it is generating this error.
0
 
LVL 10

Accepted Solution

by:
ClickCentric earned 1600 total points
ID: 16819947
Have you mirrored the database from your webserver to your localhost database?  Same database/user names, etc?
0
 

Author Comment

by:dereksheahan
ID: 16819964
Hi ClickCentric,
I nearly have it working. Once I got rid of that If statement its causing less trouble. Still not working spot on. Leave it with me for a few mins.....
0
 
LVL 17

Expert Comment

by:gops1
ID: 16821769
Can't instead of echoing putit inside a javascript string. Decalre a string global and then insert the echoed message into the variable.

<script language="javascript">
   var noRecord="";
</script>
<?php
include_once('../Connections/Map.php');

mysql_select_db($database_Map, $Map);
$result = mysql_query("SELECT * FROM subfinder",$map);
if (!$result)
{?>
<script language="javascript">
   noRecord="no result";
</script>
<?php
}
?>
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question