syntax error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
musicmancanora4
Forum Newbie
Posts: 3
Joined: Mon Sep 21, 2009 9:17 pm

syntax error

Post by musicmancanora4 »

<input name="prodId" type="hidden" value="<? echo $['idRoute']?>"> </td> it says that it is a syntax error but im not sure how it is?

Hey guys im trying to code up some product descriptions reading through a text file at i get an error on this line

your reply would be greatly appreciated

Code: Select all

 
 
 
 
<?php
session_start();
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css"/>
</head>
 
<?php
 
?>
<body>
<form id="fSample" name="fSample" method="post" action="products.php">
<select name="product">
  <option value="mobiles">Mobiles</option>
  <option value="radios">Radios</option>
  <option value="navigators">Navigators</option>
</select>
<input type="submit" name="submit" id="submit" value="Show products"/>
   <input name="prodId" type="hidden" value="<? echo $['idRoute']?>">  </td> *****Im not sure but does this error?
</form>
 
 
<!-- if user presses show products of phones, navigations etc
read declare a variable called $file and associate it with products.txt -->
 
<?php
if (isset($_POST['submit']))
{
  echo "<br/><br/>";
  echo "<table border='1'>";
  echo "<tr><th>Name</th><th>Description</th><th>Price</th></tr>";
  $file = "products.txt";
  $fp = fopen($file, 'r'); // open file for reading instead of using a database connection you read straight out of a text file
  //$counter=0;
 
  while(!feof($fp)) //while there is still data in the file keep reading until end of line
  {
  $data = fgets($fp); 
  echo $data;
  $chunk = explode(":",$data);
 
  if($_POST['product']==$chunk[0])
  {
  echo "<tr><td>$chunk[1]</td><td>$chunk[2]</td><td>$chunk[3]</td><td><a href='$chunk[4]'><input type='button' value='View details'/></a></td></tr>";
  }
  //$counter = $counter + 1;
  //echo $data;
  }
 
fclose($fp);
 
 
 
  echo "</table>";
}
?>
</body>
</html>
 
 
 
 
 
 
 
 
 
 
 
 
 
Mark Baker
Forum Regular
Posts: 710
Joined: Thu Oct 30, 2008 6:24 pm

Re: syntax error

Post by Mark Baker »

Well what is $['idRoute'] supposed to be? It isn't a valid PHP variable of any kind, and isn't referenced anywhere else in your code that I can see

Also, use long tags <?php rather than the <? short tag. You're less likely to have problems in the future
Post Reply