Jump to content

Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in C:\xam


Eoin

Recommended Posts

Hi. I am having a problem with a php while loop.I am trying to draw a polygon using coordinates from a online data table called buildinglist.the loop is supposed to loop through each row drawing a polygon with each set of coordinates :

 

<?php

// Include file to Connnect to online database

include_once "mysql_connect.php";

 

// Collects data from  table

$data = mysql_query("SELECT * FROM buildinglist")

or die(mysql_error());

// puts the "buildinglist" info into the $info array

// $info = mysql_fetch_array( $data );

 

?>

<!DOCTYPE HTML>

<html>

 

  <head>

 

        <style type="text/css">

        #theMap {background-image:url('MapImg.png'); }

        polygon:hover{fill:gold;}

        </style>

 

    <script type="text/javascript">

          // This function is called when the lake is clicked.

      function buildingClick(<?php $id ?>) {

 

        // Display a fact.

        alert("<?php print $id; ?>");

     

      }

 

    </script>

     

  </head>

 

  <body>   

      <svg id="theMap" x="0" y="0" width="900" height="900">   

 

  <?php

            while($info = mysql_fetch_array( $data )){

//THE PROBLEM IS WITH THIS LINE//

                echo "<polygon fill="$info['fill_colour']" stroke="black" id="$info['id']" points="$info['coordinates']" />";

        }

  ?>

       

    </svg>

  </body>

 

</html>

 

Can anybody help?it would be highly appreciated

Eoin.

  Quote

                echo "<polygon fill="$info['fill_colour']" stroke="black" id="$info['id']" points="$info['coordinates']" />";

I know you need to escape your quotes in the HTML

echo "<polygon fill=".$info['fill_colour']." stroke=\"black\" id=".$info['id']." points=".$info['coordinates']." />";

Should work

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.