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.

Link to comment
Share on other sites

                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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.