Page 1 of 1

unexpected T_VARIABLE

Posted: Wed Oct 02, 2002 10:27 am
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'

Posted: Wed Oct 02, 2002 10:30 am
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'

Posted: Wed Oct 02, 2002 10:40 am
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"

Posted: Wed Oct 02, 2002 10:58 am
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

Posted: Wed Oct 02, 2002 12:13 pm
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

Posted: Thu Oct 03, 2002 8:55 am
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

Posted: Thu Oct 03, 2002 9:00 am
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