我试图为两个不同的函数使用相同的代码。但是一个函数正在工作,但另一个函数不工作

These are the two functions being called, one from HTML code and one from PHP code.The function addMarker is used to add a Marker at the place which is retrieved from the database. The function codeAddressis used to place a marker at a location which is entered by the user in HTML form. The codeAdress is working fine but `addMarker' is not. I have also tried executing alert message in the addMarker function and its working fine. However the geocoder function is not working inside it. I am also writing the function calls for both the functions below the actual code.

function addMarker(address1)
{ 
geocoder.geocode( {'address': address1}, function(results, status) {
alert(address1);    
  if (status == google.maps.GeocoderStatus.OK) {
    map.setCenter(results[0].geometry.location);
    var marker = new google.maps.Marker({
        map: map,
        draggable: true,
        position: results[0].geometry.location
    });

  } else {
    alert("Geocode was not successful for the following reason: " + status);
  }
});

}



function codeAddress() {
var address = document.getElementById("address").value;
geocoder.geocode( { 'address': address}, function(results, status) {
  if (status == google.maps.GeocoderStatus.OK) {
    map.setCenter(results[0].geometry.location);
    var marker = new google.maps.Marker({
        map: map,
        draggable: true,
        position: results[0].geometry.location

    });
  }
  else {
    alert("Geocode was not successful for the following reason: " + status);
  }
});
}

The html code

<input id="address" type="textbox" value="Sydney, NSW">
<input type="button" value="Geocode" onclick="codeAddress()">

The PHP code

echo "<script type='text/javascript'>";
echo "addMarker('$row[address]')";
echo "</script>";   

$row[address] is not being evaluated here, it's just being echoed. I suspect you meant:

echo "addMarker(" . $row['address'] . ")";

But I tried to print the address1 variable in the JavaScript code using alert. And it got it printed perfectly. I don't think that's the error.