Parse error: parse error, unexpected T_VARIABLE in

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
ianhull
Forum Contributor
Posts: 310
Joined: Tue Jun 14, 2005 10:04 am
Location: Hull England UK

Parse error: parse error, unexpected T_VARIABLE in

Post by ianhull »

Parse error: parse error, unexpected T_VARIABLE in C:\Xeneo\office\index.php on line 20

If anyone can please help with this error it would be greatly appreciated.

Thanks in advance.

Code: Select all

<?php 
include ("connect.php");
$sql = "SELECT companyname, firstname, lastname, email, password, ulevel FROM users WHERE firstname='$_REQUEST[fname]' AND password='$_REQUEST[pwd]'";

$result = mysql_query($sql)
 or die ("Couldn't select $_REQUEST[fname]");

echo "

\n";

//-------------get each event type ------

while ($line = mysql_fetch_array($result))    
      {
      extract($line);      // extracts all line into variables with same name as fields 
      }
echo "\n";
$usrlevel = $ulevel 
$adminlevel = "1"; 
if ($usrlevel == $adminlevel){ 
    echo include_once("admincontent.php"); 
} else { 
    echo include_once("usercontent.php"); 
}
?>
sticksys
Forum Commoner
Posts: 33
Joined: Thu Aug 18, 2005 3:23 am
Location: Isreal
Contact:

Post by sticksys »

you forget to close the varbiel with ";"

here is the fixed code:

Code: Select all

<?php
include ("connect.php");
$sql = "SELECT companyname, firstname, lastname, email, password, ulevel FROM users WHERE firstname='$_REQUEST[fname]' AND password='$_REQUEST[pwd]'";

$result = mysql_query($sql);
or die ("Couldn't select $_REQUEST[fname]");

echo "

\n";

//-------------get each event type ------

while ($line = mysql_fetch_array($result))    
      {
      extract($line);      // extracts all line into variables with same name as fields
      }
echo "\n";
$usrlevel = $ulevel;
$adminlevel = "1";
if ($usrlevel == $adminlevel){
    echo include_once("admincontent.php");
} else {
    echo include_once("usercontent.php");
}
Last edited by sticksys on Fri Aug 19, 2005 4:25 am, edited 2 times in total.
User avatar
phpdevuk
Forum Contributor
Posts: 220
Joined: Mon Jul 04, 2005 5:31 am
Location: UK
Contact:

Post by phpdevuk »

you were missing a ; after the $result=mysql_query($sql) see below

Code: Select all

<?php 
include ("connect.php"); 
$sql = "SELECT companyname, firstname, lastname, email, password, ulevel FROM users WHERE firstname='$_REQUEST[fname]' AND password='$_REQUEST[pwd]'"; 

// the line below didn't have a ;

$result = mysql_query($sql);
or die ("Couldn't select $_REQUEST[fname]"); 

echo " 

\n"; 

//-------------get each event type ------ 

while ($line = mysql_fetch_array($result))     
      { 
      extract($line);      // extracts all line into variables with same name as fields 
      } 
echo "\n"; 
$usrlevel = $ulevel 
$adminlevel = "1"; 
if ($usrlevel == $adminlevel){ 
    echo include_once("admincontent.php"); 
} else { 
    echo include_once("usercontent.php"); 
} 
?>
sticksys
Forum Commoner
Posts: 33
Joined: Thu Aug 18, 2005 3:23 am
Location: Isreal
Contact:

Post by sticksys »

not only there,

$usrlevel = $ulevel ..



look one message up to yours :D
ianhull
Forum Contributor
Posts: 310
Joined: Tue Jun 14, 2005 10:04 am
Location: Hull England UK

Post by ianhull »

Thanks for the help.

Unfortunatly it did not work.

I have a syntax error on line 20 which is

Code: Select all

$adminlevel = "1";
Any more help wil be greatly appreciated.

Code: Select all

<?php 
include ("connect.php"); 
$sql = "SELECT companyname, firstname, lastname, email, password, ulevel FROM users WHERE firstname='$_REQUEST[fname]' AND password='$_REQUEST[pwd]'"; 

$result = mysql_query($sql) 
or die ("Couldn't select $_REQUEST[fname]"); 

echo " 

\n"; 

//-------------get each event type ------ 

while ($line = mysql_fetch_array($result))     
      { 
      extract($line);      // extracts all line into variables with same name as fields 
      } 
echo "\n"; 
$usrlevel = $ulevel 
$adminlevel = "1"; 
if ($usrlevel == $adminlevel){ 
    echo include_once("admincontent.php"); 
} else { 
    echo include_once("usercontent.php"); 
} 
?>
korto
Forum Commoner
Posts: 36
Joined: Thu Aug 18, 2005 6:30 am
Location: Greece
Contact:

Post by korto »

still missing a ; at line 19
ianhull
Forum Contributor
Posts: 310
Joined: Tue Jun 14, 2005 10:04 am
Location: Hull England UK

Post by ianhull »

Thanks Guys.

:D
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

Post by raghavan20 »

I never felt PHP to be a good interpreter.
it does not recognize missing brace and many others that are common in other languages.
if you make an error at line 55 it might show some error at 100 or 14 something like it. I usually have to recollect the last few steps or just undo wot I have done :evil:
not so rigid!!! no user friendly messages!!!
User avatar
harrisonad
Forum Contributor
Posts: 288
Joined: Fri Oct 15, 2004 4:58 am
Location: Philippines
Contact:

Re: Parse error: parse error, unexpected T_VARIABLE in

Post by harrisonad »

ianhull wrote:Parse error: parse error, unexpected T_VARIABLE in C:\Xeneo\office\index.php on line 20

Code: Select all

$usrlevel = $ulevel // <- missing semicolon
Post Reply