Link to home
Start Free TrialLog in
Avatar of Jeff
Jeff

asked on

Trying to set G-map GSM marker from a database query

I am trying to set G-map GSM marker from a database query.

$result = mysql_query("Select Street, City, State, Zip from tblOffice");

while ($row = mysql_fetch_assoc($result)) {
      echo "$x->setMarker(\"" . $row['Street'] . " " . $row['City'] . " " . $row['State'] . " " . $row['Zip'] . "\", 'red', '');\n";
}

Error Msg: Notice: Undefined property: GSM::$setMarker in ...

Thanks,
Jeff
SOLUTION
Avatar of Frozenice
Frozenice
Flag of Philippines image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Try this:

echo "<pre>";
var_dump($x); // PRINT OUT THE GSM object.

You can post the output in the code snippet, then we can see what might be wrong with  the object.
Avatar of Jeff
Jeff

ASKER

I figured out one problem. I didn't have a "\" in front of the $x->.

It is now printing the $x-> var to the screen and not inserting it into the function.

http://www.tylerwebdesign.com/examples/google_map.php
// MAKE A GOOGLE STATIC MAP OBJECT AND TEST IT OUT
$x = new GSM;

$x->clearMarkers();
$x->setZoom();
$x->setWidth(500);
$x->setHeight(400);
$x->setCenter();

while ($row = mysql_fetch_assoc($result)) {
	echo "\$x->setMarker(\"" . $row['Street'] . " " . $row['City'] . " " . $row['State'] . " " . $row['Zip'] . "\", 'red', '');\n";
}

echo $x->asIMG();

// SHOW THE OBJECT
echo "<pre>" . PHP_EOL;
print_rr($x);
echo"</pre>" . PHP_EOL;
?>

Open in new window

Let me try this again...

You can post the output in the code snippet, then we can see what might be wrong with  the object.

No offense meant at all, but looking at code that does not work is really a waste of time.  Looking at the data, and taking some iterative steps to visualize the data as we change and test the code is the way professionals work.  This article may show something of the flavor of what I am getting at when I say, "Show me the data."
https://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_7830-A-Quick-Tour-of-Test-Driven-Development.html
Avatar of Jeff

ASKER

Not sure where to put the var dump. I hope this is what you need.

Without Var Dump it prints this to screen:
$x->setMarker("811 S.Central Expressway Suite 300G Richardson TX 75080", 'red', '');$x->setMarker("6119 Greenville Ave # 192 Dallas TX 75206", 'red', '');$x->setMarker("1084 County RD 3480 Hawkians TX 75765", 'red', '');

With Var Dump it prints this to screen:
$x->setMarker("811 S.Central Expressway Suite 300G Richardson TX 75080", 'red', '');$x->setMarker("6119 Greenville Ave # 192 Dallas TX 75206", 'red', '');$x->setMarker("1084 County RD 3480 Hawkians TX 75765", 'red', '');object(GSM)#1 (16) {
  ["center:protected"]=>
  NULL
  ["markers:protected"]=>
  array(0) {
  }
  ["default_icon:protected"]=>
  string(54) "http://maps.google.com/mapfiles/ms/micons/question.png"
  ["maptype:protected"]=>
  string(7) "roadmap"
  ["width:protected"]=>
  int(500)
  ["height:protected"]=>
  int(400)
  ["zoom:protected"]=>
  NULL
  ["format:protected"]=>
  string(3) "png"
  ["alt:protected"]=>
  bool(false)
  ["title:protected"]=>
  bool(true)
  ["class:protected"]=>
  bool(false)
  ["id:protected"]=>
  bool(false)
  ["usemap:protected"]=>
  bool(false)
  ["sensor:protected"]=>
  bool(false)
  ["url:protected"]=>
  bool(false)
  ["img:private"]=>
  string(158) "
Avatar of Jeff

ASKER

Looks like an awesome article. I read the first paragraph and got this big lump in my throat! Yep, that's me. So what do I do? Run down to the book store and buy "Apple Pies for Dummies"! Problem is it just doesn't taste as good.

I will print it out and start reading. Have you published any programming books?
Avatar of Jeff

ASKER

When I hard code the addresses it prints this:

object(GSM)#1 (16) {
  ["center:protected"]=>
  NULL
  ["markers:protected"]=>
  array(3) {
    [0]=>
    array(4) {
      ["color"]=>
      string(3) "red"
      ["label"]=>
      string(0) ""
      ["geocode"]=>
      string(55) "811 S.Central Expressway Suite 300G Richardson TX 75080"
      ["icon"]=>
      bool(false)
    }
    [1]=>
    array(4) {
      ["color"]=>
      string(3) "red"
      ["label"]=>
      string(0) ""
      ["geocode"]=>
      string(41) "6119 Greenville Ave # 192 Dallas TX 75206"
      ["icon"]=>
      bool(false)
    }
    [2]=>
    array(4) {
      ["color"]=>
      string(3) "red"
      ["label"]=>
      string(0) ""
      ["geocode"]=>
      string(37) "1084 County RD 3480 Hawkians TX 75765"
      ["icon"]=>
      bool(false)
    }
  }
  ["default_icon:protected"]=>
  string(54) "http://maps.google.com/mapfiles/ms/micons/question.png"
  ["maptype:protected"]=>
  string(7) "roadmap"
  ["width:protected"]=>
  int(500)
  ["height:protected"]=>
  int(400)
  ["zoom:protected"]=>
  NULL
  ["format:protected"]=>
  string(3) "png"
  ["alt:protected"]=>
  bool(false)
  ["title:protected"]=>
  bool(true)
  ["class:protected"]=>
  bool(false)
  ["id:protected"]=>
  bool(false)
  ["usemap:protected"]=>
  bool(false)
  ["sensor:protected"]=>
  bool(false)
  ["url:protected"]=>
  bool(false)
  ["img:private"]=>
  string(369) ""
}
Note this part near the bottom of the var_dump() output.
["img:private"]=>
  string(369) ""

You will need to use "view source" to see what is actually in that variable.  More to follow...
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jeff

ASKER

Thanks to you both. I have gone a different direction.