[SOLVED]syntax error, unexpected T_CONSTANT_ENCAPSED_STRING

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
User avatar
evilchris2003
Forum Contributor
Posts: 106
Joined: Sun Nov 12, 2006 6:43 am
Location: Derby, UK

[SOLVED]syntax error, unexpected T_CONSTANT_ENCAPSED_STRING

Post by evilchris2003 »

Hi

I havent done much developing in a while and am a little stuck on this error
Google has done little to help but from what i have read this can have something to do with config files
I am using Xampp for windows ver 1.6.0a if this helps
the error is on the echo "<td>". $array['Actors']. "</td>"; line although i cant see anything on the surrounding lines either

Code: Select all

if ($results >= 1)
	{
	foreach ($results as $array)
		{
		echo "<tr><td>". $array['Name']. "</td>";
		echo "<td>". $array['Actors']. "</td>";
		echo "<td>". $array['Descripton']. "</td>";
		echo "<td>". $array['Year']. "</td>";
		echo "<td><a href=". $results ['Location']. "></td>";
		echo "<td>". $array ['Backup']. "</td></tr>";
		}
	}
Last edited by evilchris2003 on Tue Apr 03, 2007 8:51 am, edited 1 time in total.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

It doesn't look like you've posted enough code. That looks fine to me. Usually that error crops up when you forget the "." during concatenation or you miss a semi-colon, or you try placing " in a double-quoted string without escaping it.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Your code is quite odd.
User avatar
evilchris2003
Forum Contributor
Posts: 106
Joined: Sun Nov 12, 2006 6:43 am
Location: Derby, UK

Post by evilchris2003 »

OK heres the full file and @ feyd what is odd about it although ive done a bit of php in the past i would still class myself as a newbie

Code: Select all

<?php # Search Page

$page_title = 'Search The Database';

include ('./header.inc');
if (!isset($_POST['submit']))

	echo 'Use the fields below to search the database<br><br>

	<form method=POST action="#">
	
		Film Name: <input type="text" name="film_name" value="Enter a keyword to search" size="30" length="100"><br>
		Actor name: <input type="text" name="actor_name" value="Enter a name" size="30" length="100"><br>
		Year Released: <input type="text" name="year_released" value="Enter a year" size="6" length="4"><br>
		<input type="submit" name="submit" value="Search The Database">
		<input type="reset" name="clear" value="Clear Form">
	
	</form>';

else 
	include('../mysql_connect.php');
	$query = "SELECT Name, Actors, Description, Year, Location, Backup FROM films WHERE (Name='film_name' OR Actors='actor_name' OR Year='year_released');
	$results = @mysql_query($query) or die (mysql_error());
	$array = mysql_fetch_array($results)
?>
<table width=100% align=center border=0 cellspacing=5>
<tr><td>Name</td><td>Actors</td><td>Description</td><td>Year</td><td>Location</td><td>Backed Up</td></tr>
<?php
if ($results >= 1)
	{
	foreach ($results as $array)
		{
		//echo "";
		echo "<tr><td>". $array['Name']. "</td>";
		echo "<td>". $array['Actors']. "</td>";
		echo "<td>". $array['Descripton']. "</td>";
		echo "<td>". $array['Year']. "</td>";
		echo "<td><a href=". $array ['Location']. "></td>";
		echo "<td>". $array ['Backup']. "</td></tr>";
		}
	}
else
	{
		echo '<font color="red"> There are no results for the keywords'. $_POST['film_name']. ', '. $_POST['actor_name'].
			', '. $_POST['year_released']. 'Please try again';
                }
?>
</table><br>
<a href="#">Search Again<a>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Your $query is not terminated by a double quote.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Look at the way your code all went red above:

Code: Select all

$query = "SELECT Name, Actors, Description, Year, Location, Backup FROM films WHERE (Name='film_name' OR Actors='actor_name' OR Year='year_released');
Should be

Code: Select all

$query = "SELECT Name, Actors, Description, Year, Location, Backup FROM films WHERE (Name='film_name' OR Actors='actor_name' OR Year='year_released')";
User avatar
evilchris2003
Forum Contributor
Posts: 106
Joined: Sun Nov 12, 2006 6:43 am
Location: Derby, UK

Post by evilchris2003 »

Aggg always miss the obvious things

thanks guys
Post Reply