1 Replies - 482 Views - Last Post: 26 March 2009 - 02:15 PM Rate Topic: -----

#1 chrisp200  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 82
  • Joined: 18-November 08

Parse error

Posted 26 March 2009 - 02:10 PM

I am getting an error on this php page

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\Program_Files\wamp\www\tutorial04\descript.php on line 28

line 28 is
	$sql = "SELECT * FROM topics WHERE `id` = '$_GET['id']'";



im assuming it has something to do with the $_GET[id] , am i correct?



heres the whole page
<?php

	mysql_connect("localhost","root") or die (mysql_error());
	mysql_select_db("tutorial04") or die (mysql_error());
	
	?>
	<center>
	

<table border="0" style="color:white; font-size: 15px; font-family:tahoma">
	
		
		<td width="200"style="background-color:gray; border: 1px solid black; margin-left:5px"/> 
			Job Description:
		</td>
	
	
			
		</center>
	
	</table>
	

	
	
	<?php
	
	$sql = "SELECT * FROM topics WHERE `id` = '$_GET['id']'";
	$res = mysql_query($sql) or die (mysql_error());
	
	while($row = mysql_fetch_array($res)) {
		
		
	
?>
<table border="0" style="color:black; padding:2px; font-size: 15px; font-family:tahoma">
	<tr style="color: black">
		<td width="200" style="background-color:white; border: 1px solid black; margin-left:5px"/>
			<?php echo $row['descript']; ?>
		</td>
		
		
	
	</tr>
	</table>
	<?php
}

?>



Is This A Good Question/Topic? 0
  • +

Replies To: Parse error

#2 ghqwerty  Icon User is offline

  • if($spareTime > 0){ $this->writeCode(); }
  • member icon

Reputation: 43
  • View blog
  • Posts: 903
  • Joined: 08-August 08

Re: Parse error

Posted 26 March 2009 - 02:15 PM

$sql = "SELECT * FROM topics WHERE id = ".$_GET['id']."";

that will work however i would reccommend using post for sensitive data so that people cant just read it from the url, which will increase security.

the problem as is you had too many single ' without breaking them up so it read it as where id = $_GET[]. i have concatenated it to the code using a period (.)
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1