unexpected T_VARIABLE

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
cereal
Forum Newbie
Posts: 8
Joined: Wed Oct 02, 2002 10:27 am
Location: Belgium
Contact:

unexpected T_VARIABLE

Post by cereal »

k, what doe sthis error mean?

Parse error: parse error, unexpected T_VARIABLE in d:\phpdev5\www\public\projects\xtrition\poems.php on line 52

Code: Select all

<? $edge_cleanpage = true; ?>
<? include('poems.config.php') ?>
<? include('edge.header.php'); ?>
<?
	$tem = (int)$tem;
	$fil = checkstr_($fil);
?>
<br>
<br>
<? 
   if ($tem='')
	&#123;
		echo '<center><a href=poems.php?tem=1>'.$edge_poem&#1111;1].'</a><br>
			<a href=poems.php?tem=0>'.$edge_poem&#1111;0].'</a></center>';	
	&#125;
   else
	&#123;
		edge_do_title('<font size=-1>'.$edge_poem&#1111;$tem].'</font>');
		if (!$fil)
			&#123;
				echo 'please choose the auhors name.<br>';
				echo '<a href=poems.php?tem='.$tem.'&fil=a>a</a> - 
					<a href=poems.php?tem='.$tem.'&fil=b>b</a> - 
					<a href=poems.php?tem='.$tem.'&fil=c>c</a> - 
					<a href=poems.php?tem='.$tem.'&fil=d>d</a> - 
					<a href=poems.php?tem='.$tem.'&fil=e>e</a> - 
					<a href=poems.php?tem='.$tem.'&fil=f>f</a> - 
					<a href=poems.php?tem='.$tem.'&fil=g>g</a> - 
					<a href=poems.php?tem='.$tem.'&fil=h>h</a> - 
					<a href=poems.php?tem='.$tem.'&fil=i>i</a> - 
					<a href=poems.php?tem='.$tem.'&fil=j>j</a> - 
					<a href=poems.php?tem='.$tem.'&fil=k>k</a> - 
					<a href=poems.php?tem='.$tem.'&fil=l>l</a> - 
					<a href=poems.php?tem='.$tem.'&fil=m>m</a> - 
					<a href=poems.php?tem='.$tem.'&fil=n>n</a> - 
					<a href=poems.php?tem='.$tem.'&fil=o>o</a> - 
					<a href=poems.php?tem='.$tem.'&fil=p>p</a> - 
					<a href=poems.php?tem='.$tem.'&fil=q>q</a> - 
					<a href=poems.php?tem='.$tem.'&fil=r>r</a> - 
					<a href=poems.php?tem='.$tem.'&fil=s>s</a> - 
					<a href=poems.php?tem='.$tem.'&fil=t>t</a> - 
					<a href=poems.php?tem='.$tem.'&fil=u>u</a> - 
					<a href=poems.php?tem='.$tem.'&fil=v>v</a> - 
					<a href=poems.php?tem='.$tem.'&fil=w>w</a> - 
					<a href=poems.php?tem='.$tem.'&fil=x>x</a> - 
					<a href=poems.php?tem='.$tem.'&fil=y>y</a> - 
					<a href=poems.php?tem='.$tem.'&fil=z>z</a>';
					
			&#125;
		else
			&#123;
				$quer = 'SELECT * FROM poems WHERE author like '%$fil%' AND theme='$edge_poem&#1111;$tem]' ORDER BY author'
			&#125;
	&#125;

?>

<? include('edge.footer.php'); ?>
its this line

Code: Select all

$quer = 'SELECT * FROM poems WHERE author like '%$fil%' AND theme='$edge_poem&#1111;$tem]' ORDER BY author'
Last edited by cereal on Wed Oct 02, 2002 10:33 am, edited 1 time in total.
User avatar
mydimension
Moderator
Posts: 531
Joined: Tue Apr 23, 2002 6:00 pm
Location: Lowell, MA USA
Contact:

Post by mydimension »

in this line (i think): $quer = 'SELECT * FROM poems WHERE author like '%$fil%' AND theme='$edge_poem[$tem]' ORDER BY author'
you need to use the concatenate operator ( . ) to join multiple stings. it shouls look like this:
$quer = 'SELECT * FROM poems WHERE author like ' . %$fil% . ' AND theme=' . $edge_poem[$tem] . ' ORDER BY author'
User avatar
Wayne
Forum Contributor
Posts: 339
Joined: Wed Jun 05, 2002 10:59 am

Post by Wayne »

try replacing

Code: Select all

$quer = 'SELECT * FROM poems WHERE author like '%$fil%' AND theme='$edge_poem&#1111;$tem]' ORDER BY author'
with

Code: Select all

$quer = "SELECT * FROM poems WHERE author like '%$fil%' AND theme='$edge_poem&#1111;$tem]' ORDER BY author"
User avatar
cereal
Forum Newbie
Posts: 8
Joined: Wed Oct 02, 2002 10:27 am
Location: Belgium
Contact:

Post by cereal »

mydimension wrote:in this line (i think): $quer = 'SELECT * FROM poems WHERE author like '%$fil%' AND theme='$edge_poem[$tem]' ORDER BY author'
you need to use the concatenate operator ( . ) to join multiple stings. it shouls look like this:
$quer = 'SELECT * FROM poems WHERE author like ' . %$fil% . ' AND theme=' . $edge_poem[$tem] . ' ORDER BY author'
well this did the trick, thanks
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Shouldn't this:

Code: Select all

$quer = 'SELECT * FROM poems WHERE author like ' . %$fil% . ' AND theme=' . $edge_poem&#1111;$tem] . ' ORDER BY author'
be

Code: Select all

$quer = "SELECT * FROM poems WHERE author like '%".$fil."%'  AND theme='". $edge_poem&#1111;$tem]."' ORDER BY author";
You really need single quotes around strings when you are writing a query and the wilcards (% symbols) need to be inside the string not next to the variable name.

Mac
User avatar
cereal
Forum Newbie
Posts: 8
Joined: Wed Oct 02, 2002 10:27 am
Location: Belgium
Contact:

Post by cereal »

well now i get the same error in this script

Code: Select all

<table border = "0">
<tr>
	<td>Nick</td><td>Real Name</td>
</tr>
<?
	$q = "Select * From people WHERE betaald = '2' ORDER BY nick"
	$res = mysql_db_query($edge_database,$q,$mysql);
	while ($row = mysql_fetch_object($res))
	&#123;
		echo '<tr><td>' . $row->nick . '</td><td>' . $row->name . '</td></tr>';
	&#125;
?>
</table>
in this line

Code: Select all

$res = mysql_db_query($edge_database,$q,$mysql);
Cereal
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

You forgot a semi-colon (;) at the end of this line:

Code: Select all

$q = "Select * From people WHERE betaald = '2' ORDER BY nick"
Don't use mysql_db_query() it has been deprecated, use mysql_select_db() and mysql_query() instead. You should also add some error handling. Eg. this:

Code: Select all

mysql_select_db($edge_database) or die(mysql_error());
$res = mysql_query($q) or die(mysql_error());
instead of

Code: Select all

$res = mysql_db_query($edge_database,$q,$mysql);
Mac
Post Reply