Page 1 of 1
[SOLVED]syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
Posted: Tue Apr 03, 2007 7:19 am
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>";
}
}
Posted: Tue Apr 03, 2007 7:34 am
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.
Posted: Tue Apr 03, 2007 7:35 am
by feyd
Your code is quite odd.
Posted: Tue Apr 03, 2007 7:43 am
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>
Posted: Tue Apr 03, 2007 8:04 am
by feyd
Your $query is not terminated by a double quote.
Posted: Tue Apr 03, 2007 8:04 am
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')";
Posted: Tue Apr 03, 2007 8:36 am
by evilchris2003
Aggg always miss the obvious things
thanks guys