1.11M Members

Google Maps disappear PHP

 
0
 

Dear Sirs!

I have this php syntax in my <head>.

         <?php
        // MySQL
        mysql_connect("localhost", "fundis_petrol", "petrol123") or die(mysql_error());
        mysql_select_db("fundis_petrol") or die(mysql_error());

        // Table
        $result = mysql_query("SELECT * FROM  `fillingstations` LIMIT 0 , 30")
        or die(mysql_error());  


        // Print

        while($row = mysql_fetch_array($result)){
        echo $row[2];
        }

        ?>  

And I also have this JS (Google Maps API) in my <head>.

    var beaches = [
      ['Miskolci road / Shell Station', <?php echo $row[2]; ?> , 4],
      ['Szabadsag utja / Töltöallomas', 47.559025, 19.281415, 5],
      ['Cronulla Beach', -34.028249, 151.157507, 3],
      ['Manly Beach', -33.80010128657071, 151.28747820854187, 2],
      ['Maroubra Beach', -33.950198, 151.259302, 1]
    ];

But when I try to echo the number with a PHP syntax in my Javascript, the whole map disappears.
I think that it is a wrong way of outputting the number there..

I would be grateful if you could help me,

Tibor :)

 
0
 

In my opinion, it's a bit different question. Now I have syntax error, in the other thread I needed a simple code. But I accept your query.

LastMitch
Deleted Member
 
0
 

@tibormarias

In my opinion, it's a bit different question. Now I have syntax error, in the other thread I needed a simple code. But I accept your query.

It does look the same

<?php
// MySQL
mysql_connect("localhost", "", "") or die(mysql_error());
mysql_select_db("") or die(mysql_error());
// Table
$result = mysql_query("SELECT * FROM `fillingstations` LIMIT 0 , 30")
or die(mysql_error());
// Print
while($row = mysql_fetch_array($result)){
echo 'Station name: '. $row[1];
echo 'LatLng: '. $row[2];
echo 'Price: '. $row[3];
}
?> 

-

var beaches = [
['Miskolci road / Shell Station', !!!!Lation!!!! 4],
['Szabadsag utja / Töltöallomas', 47.559025, 19.281415, 5],
['Cronulla Beach', -34.028249, 151.157507, 3],
['Manly Beach', -33.80010128657071, 151.28747820854187, 2],
['Maroubra Beach', -33.950198, 151.259302, 1]
];

Explain to me are you back to square 1?

 
0
 

What is in $row[2] ?

 
0
 

"47.559025,19.281415" that is in row[2] without quotation marks.

Question Answered as of 1 Year Ago by LastMitch and pritaeas
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: