...

View Full Version : parse error: unexpected $



g0liatH
10-08-2004, 07:49 PM
Hi,

I have a code and I can't seem to find the parse error :mad:

can someone help me please?

this is the error:

Parse error: parse error, unexpected $ in /home/virtual/site51/fst/var/www/html/td/mainnew/header.php on line 253

line 253 is the last line of the script so :confused:

here's the script

header.php



<?
define('IN_PHPBB', true);

$site_root_path = '/home/virtual/site51/fst/var/www/html/';
$phpbb_root_path2 = '/forum/';
$phpbb_root_path = $site_root_path . $phpbb_root_path2;
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.php');

$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
?>
<?
if($userdata['session_logged_in']){ //logged in

if ( $userdata['user_new_privmsg'] ) //private messages by AJ Quick
{
$l_message_new = ( $userdata['user_new_privmsg'] == 1 ) ? $lang['New_pm'] : $lang['New_pms'];
$l_privmsgs_text = sprintf($l_message_new, $userdata['user_new_privmsg']);

if ( $userdata['user_last_privmsg'] > $userdata['user_lastvisit'] )
{
$sql = "UPDATE " . USERS_TABLE . "
SET user_last_privmsg = " . $userdata['user_lastvisit'] . "
WHERE user_id = " . $userdata['user_id'];
if ( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not update private message new/read time for user', '', __LINE__, __FILE__, $sql);
}

$s_privmsg_new = 1;
$icon_pm = $images['pm_new_msg'];
}
else
{
$s_privmsg_new = 0;
$icon_pm = $images['pm_no_new_msg'];
}

}
else
{
$l_privmsgs_text = $lang['No_new_pm'];

$s_privmsg_new = 0;
$icon_pm = $images['pm_no_new_msg'];
}

if ( $userdata['user_unread_privmsg'] )
{
$l_message_unread = ( $userdata['user_unread_privmsg'] == 1 ) ? $lang['Unread_pm'] : $lang['Unread_pms'];
$l_privmsgs_text_unread = sprintf($l_message_unread, $userdata['user_unread_privmsg']);
}
else
{
$l_privmsgs_text_unread = $lang['No_unread_pm'];
}

} // if user logged in
?>

<HTML>
<HEAD>
{META}
{NAV_LINKS}
<TITLE>Tomorrows Designers :: <? echo("$title") ?></TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<script language="javascript" type="text/javascript" src="alljava.js">
</script>
<?php
if ( !empty($userdata['user_popup_pm']) ){
?>
<script language="Javascript" type="text/javascript">
<!--
if (<?php echo $s_privmsg_new ?>)
{
window.open('<?php echo $phpbb_root_path2 ."privmsg.".$phpEx."?mode=newpm" ?>', '_phpbbprivmsg', 'HEIGHT=225,resizable=yes,WIDTH=400');;
}
//-->
</script>
<?php
}
?>
</HEAD>
<LINK REL="STYLESHEET" type="text/css" href="td.css">
<?
if($what == 'Forum') { echo'
<body bgcolor="{T_BODY_BGCOLOR}" text="{T_BODY_TEXT}" link="{T_BODY_LINK}" vlink="{T_BODY_VLINK}">'; }
else { echo'
<BODY BGCOLOR=#FFFFFF LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0>'; }
?>
<table height="100%" width=100% border=0 cellpadding=0 cellspacing=0>
<tr>
<td height="134" colspan="9"> <table border=0 cellpadding=0 cellspacing=0>
<tr>
<td width="134"> <img src="images/tdlogo.png" width=134 height=102 alt=""></td>
<td colspan="12" background="images/vertup.png">&nbsp; </td>
</tr>
<tr>
<td background="images/vertmid.png"></td>
<td width="63"> <img onMouseOver="" src="images/home.png" width=63 height=32

alt=""></td>
<td width="91"> <img src="images/about.png" width=91 height=32 alt=""></td>
<td width="101"> <img src="images/forums.png" width=101 height=32 alt=""></td>
<td width="83"> <img src="images/faq.png" width=83 height=32 alt=""></td>
<td width="127"> <img src="images/contact.png" width=127 height=32 alt=""></td>
<td width="117"> <img src="images/downloads.png" width=117 height=32 alt=""></td>
<td width="75"> <img src="images/extra.png" width=75 height=32 alt=""></td>
<td width="228" background="images/vertmid.png">&nbsp; </td>
</tr>
</table></td>
<tr>
<td width="225" valign="top"> <br> <br>
<table width="198" border="0" align="center" cellpadding="0" cellspacing="0"

background="images/navmid.png">
<tr>
<td height="20" valign="bottom" background="images/navup.png"><div

align="center">Menu</div></td>
</tr>
<tr>
<td><div align="center"><br>
</div></td>
</tr>
<tr>
<td><div align="center"><a href="testtd.php">Home</a></div></td>
</tr>
<tr>
<td><div align="center"><a href="abouttd.php">About us</a></div></td>
</tr>
<tr>
<td><div align="center">Forums</div></td>
</tr>
<tr>
<td><div align="center">FAQ</div></td>
</tr>
<tr>
<td><div align="center">Contact us</div></td>
</tr>
<tr>
<td><div align="center"></div>
<div align="center"><a href="extratd.php">Extra</a></div></td>
</tr>
<tr>
<td><div align="center"><a href="<?php echo $phpbb_root_path2 ?>privmsg.php?folder=inbox"><?php echo $l_privmsgs_text ?></a></div></td>
</tr>
<tr>
<td height="20" background="images/navdown.png"><div align="center"></div></td>
</tr>
</table>
<br> <br>
<? if($what !== 'post' or 'Forum') { echo '
<table width="198" border="0" align="center" cellpadding="0" cellspacing="0"

background="images/navmid.png">
<tr>
<td height="20" valign="bottom" background="images/navup.png"><div

align="center">'; echo "Latest $what"; echo '</div></td>
</tr>
<tr>
<td><div align="center"><br>
</div></td>
</tr>
<tr>
<td><div align="center"> </div>
<div align="center">';

include('db.php');

$q = mysql_query("SELECT * FROM $table ORDER BY id DESC LIMIT 5");
// That queries the database



while($r=mysql_fetch_array($q)){

$title = $r["title"];

$news = $r["news"];

$body = nl2br($news);

$author = $r["author"];

$link = "mailto:".$r["email"];

$date = $r["date"];

echo "$title<br>";

}
mysql_close($cnx);

echo '</div>
<div align="center"></div></td>
</tr>
<tr>
<td height="20" background="images/navdown.png"><div align="center"></div></td>
</tr>
</table>';
?>
<br><br>
<? if($what == 'Forum') { echo '
<table width="198" border="0" align="center" cellpadding="0" cellspacing="0"

background="images/navmid.png">
<tr>
<td height="20" valign="bottom" background="images/navup.png"><div

align="center">Forum</div></td>
</tr>
<tr>
<td><div align="center"><br>
</div></td>
</tr>
<tr>
<td><div align="center"><a href="index.php">Index</a></div></td>
</tr>
<tr>
<td><div align="center"><span class="mainmenu"><a href="{U_MEMBERLIST}" class="mainmenu">{L_MEMBERLIST}</a></span></div></td>
</tr>
<tr>
<td><div align="center"><span class="mainmenu"><a href="{U_REGISTER}" class="mainmenu">{L_REGISTER}</a></span></div></td>
</tr>
<tr>
<td><div align="center"><span class="mainmenu"><a href="{U_PROFILE}" class="mainmenu">{L_PROFILE}</a></span></div></td>
</tr>
<tr>
<td><div align="center"><span class="mainmenu"><a href="{U_SEARCH}" class="mainmenu">{L_SEARCH}</a></span></div></td>
</tr>
<tr>
<td><div align="center"></div>
<div align="center" class="mainmenu"><a href="{U_FAQ}" class="mainmenu">{L_FAQ}</a></div></td>
</tr>
<tr>
<td><div align="center"><span class="mainmenu"><a href="{U_GROUP_CP}" class="mainmenu">{L_USERGROUPS}</a></span></div></td>
</tr>
<tr>
<td><div align="center"><span class="mainmenu"><a href="{U_PRIVATEMSGS}" class="mainmenu">{PRIVATE_MESSAGE_INFO}</a></span></div></td>
</tr>
<tr>
<td><div align="center"><span class="mainmenu"><a href="{U_LOGIN_LOGOUT}" class="mainmenu">{L_LOGIN_LOGOUT}</a></span></div></td>
</tr>
<tr>
<td height="20" background="images/navdown.png"><div align="center"></div></td>
</tr>
</table>'; }
?>
</td>


thanks

Hawkmoon
10-08-2004, 08:14 PM
Hey Goliath,

That's a lot of code to look over. If you narrow it down it would be a ton easier to find the problem. A good trick for trouble shooting is to start at the top of your code and comment EVERYTHING out. Then go step by step and UNCOMMENT small sections of your code at a time to isolate where the error is being produced. Like so:


<?
/*
function doSomething() {
return "Inside Do Something";
}
echo(doSomething());
echo("This line will cause an error<br>")
echo("This line is fine");
*/
?>


Then go section by section:


<?
function doSomething() {
return "Inside Do Something";
}
echo(doSomething());
/*
echo("This line will cause an error<br>")
echo("This line is fine");
*/

//*NOTE:This will return good code, but if you uncomment the next line you'll get an error.
?>

g0liatH
10-08-2004, 08:18 PM
thanks Hawkmoon. Didn't think of that, I will try it right now :)

Hawkmoon
10-08-2004, 08:22 PM
Cool. Let me know how it goes. If you can isolate the error and are still having problems, post the code and I'll take a look.

g0liatH
10-08-2004, 08:27 PM
Great tip, thanks!

I found the code but I'm still a beginner at php :o



if($what !== 'post' or $what !== 'Forum') { echo '
<table width="198" border="0" align="center" cellpadding="0" cellspacing="0"

background="images/navmid.png">
<tr>
<td height="20" valign="bottom" background="images/navup.png"><div

align="center">'; echo "Latest $what"; echo '</div></td>
</tr>
<tr>
<td><div align="center"><br>
</div></td>
</tr>
<tr>
<td><div align="center"> </div>
<div align="center">';

include('db.php');

$q = mysql_query("SELECT * FROM $table ORDER BY id DESC LIMIT 5");
// That queries the database



while($r=mysql_fetch_array($q)){

$title = $r["title"];

$news = $r["news"];

$body = nl2br($news);

$author = $r["author"];

$link = "mailto:".$r["email"];

$date = $r["date"];

echo "$title<br>";

}
mysql_close($cnx);

echo '</div>
<div align="center"></div></td>
</tr>
<tr>
<td height="20" background="images/navdown.png"><div align="center"></div></td>
</tr>
</table>';

?>
<br><br>


It probably has something to do with the 'or' eh?

the sql code works, I tested that before so it can't be that.

Hawkmoon
10-08-2004, 08:31 PM
The "or" is ok...but you're right about the problem is with your if() section.
This should work:


<?
if($what != 'post' OR $what != 'Forum') {
echo '<table width="198" border="0" align="center" cellpadding="0" cellspacing="0" background="images/navmid.png">
<tr>
<td height="20" valign="bottom" background="images/navup.png"><div align="center">';
echo "Latest $what";
echo '</div></td>
</tr>
<tr>
<td><div align="center"><br>
</div></td>
</tr>
<tr>
<td><div align="center"> </div>
<div align="center">';
}
//*NOTE- IMPORTANT! You need the closing bracket for your if statement
?>

g0liatH
10-08-2004, 08:41 PM
thanks, it works now. I added the closing bracket :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum