Forum Moderators: coopster

Message Too Old, No Replies

can you find the unexpected T VARIABLE?

coz i cant!

         

PartisanEntity

5:17 pm on Jan 4, 2010 (gmt 0)

10+ Year Member



For the life of me I cannot find what's wrong with this. I have poured over again and again and also in various editors with different kinds of syntax highlighting:

<?php
//if the admin or a mod accesses this page, show the form
if ($_SESSION['logged_in'] == 1 && $_SESSION['username'] == "admin" ¦¦ $_SESSION['function'] == 1) {
echo '<h2>Write News</h2>';
echo '<form action="news_func.php" method="post">';
echo '<table>';
echo '<tr><td width="50px">Author: </td><td><b>'.$_SESSION['username'].' </b></td></tr>';
echo '<tr><td width="50px">Title: </td><td><input type="text" name="nform_title"></td></tr>';
echo '<tr><td width="50px">Text: </td><td><textarea name="nform_text" cols=40 rows=6></textarea></td></tr>';
echo '<input type="hidden" name="nform_date" value="'.date("F j, Y, g:i a").' ">';
echo '<input type="hidden" name="nform_author" value="'.$_SESSION['username'].' ">';
echo '<tr><td></td><td><input type="submit"></td></tr>';
echo '</table>';
echo '</form>';
} else {
//otherwise this user has no business here
echo 'Access denied';
}
?>

mack

5:42 pm on Jan 4, 2010 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



have you tried escaping the "s in the html you are echoing?
echo '<tr><td width=\"50px\">Author: </td><td><b>'.$_SESSION['username'].' </b></td></tr>';

Mack.

PartisanEntity

6:36 pm on Jan 4, 2010 (gmt 0)

10+ Year Member



I thought I didn't have to worry about escaping the " if I used ' ?

PartisanEntity

6:39 pm on Jan 4, 2010 (gmt 0)

10+ Year Member



Just tried escaping the ", still shows error about an unexpected T VARIABLE

dreamcatcher

6:44 pm on Jan 4, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That code looks fine. Are you sure the error is from those lines and not from a previous line?

dc

StoutFiles

6:48 pm on Jan 4, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Runs fine for me. If you took that code from this site originally you'll need to change the OR statement (¦¦) to solid lines instead of dashed lines.

PartisanEntity

6:55 pm on Jan 4, 2010 (gmt 0)

10+ Year Member



I am not sure why the dashed lines showed up here on the forum.

On the Mac in the editor I pressed ALT+7 to get the ¦¦ <-- not sure why this is happening here on the forum, just before I pressed submit on this post they two lines had no dashes in them.

StoutFiles

6:58 pm on Jan 4, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The forum does that automatically to any pipe symbols; I assume for security reasons. Just making sure they are solid in your original code.

Most PHP errors come with a line number. What line of the code is incorrect?

PartisanEntity

7:01 pm on Jan 4, 2010 (gmt 0)

10+ Year Member



Line 3 is incorrect according to the error.

The strange thing is that if I cut out this bit of the IF statement:

&& ($_SESSION['username'] == "admin" ¦¦ $_SESSION['function'] == 1)

...then it works and displays the form.

Just as a test I even changed it to:

&& ($_SESSION['username'] == "admin" && $_SESSION['function'] == 1)

replaced the ¦¦ with && and it displayed the same error again.

PartisanEntity

7:04 pm on Jan 4, 2010 (gmt 0)

10+ Year Member



Okay, I got it, the order of the operators was wrong, hence the error.

It worked in this order:

(($_SESSION['username'] == "admin" ¦¦ $_SESSION['function'] == 1) && $_SESSION['logged_in'] == 1)