php parse error, unexpected T_VARIABLE...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bovanshi
    New Member
    • Nov 2006
    • 2

    php parse error, unexpected T_VARIABLE...

    got this annoying error

    I'm completly new to php... and i have no clue what is wrong here, from what i can tell there is nothing rong with this code... but that isn't what the borwser say :P

    Parse error: parse error, unexpected T_VARIABLE in main.php on line 15

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
    <html>
    <head>
    <title></title>
    <head/>
    <body style="backgrou nd-color: transparent">
    <?php
    $file=fopen("ne ws.txt","r") or exit("Unable to open file!");
    $first = 1
    $ordn = fgetc($file);
    fgets($file);
    while (!feof($file))
    {
    if $first = 1
    {
    $check = fgetc($file);
    $first = 0
    }
    if $check = "_"
    {
    $check = fgetc($file);
    }
    if $check = $ordn
    {
    $ordn = $ordn - 1
    while $check(!"_")
    {
    echo fgets($file);
    $check = fgetc($file);
    }
    }
    else
    {
    fgets($file);
    $check = fgetc($file);
    }
    }
    fclose($file);
    ?>
    </body>
    </html>

    NEXT TIME ENCLOSE YOUR CODE WITHIN PHP, CODE OR HTML TAGS!! READ THE POSTING GUIDLINES BEFORE POSTING ANYTHING IN THIS FORUM! - Ronald :cool:
  • scriptee
    New Member
    • Nov 2006
    • 17

    #2
    Originally posted by bovanshi
    got this annoying error

    I'm completly new to php... and i have no clue what is wrong here, from what i can tell there is nothing rong with this code... but that isn't what the borwser say :P

    Parse error: parse error, unexpected T_VARIABLE in main.php on line 15

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
    <html>
    <head>
    <title></title>
    <head/>
    <body style="backgrou nd-color: transparent">
    <?php
    $file=fopen("ne ws.txt","r") or exit("Unable to open file!");
    $first = 1
    $ordn = fgetc($file);
    fgets($file);
    while (!feof($file))
    {
    if $first = 1
    {
    $check = fgetc($file);
    $first = 0
    }
    if $check = "_"
    {
    $check = fgetc($file);
    }
    if $check = $ordn
    {
    $ordn = $ordn - 1
    while $check(!"_")
    {
    echo fgets($file);
    $check = fgetc($file);
    }
    }
    else
    {
    fgets($file);
    $check = fgetc($file);
    }
    }
    fclose($file);
    ?>
    </body>
    </html>
    Hi bovanshi,

    You have missed the required semicolons and the ( ) in your if () statements. Your if statement conditions should be always inside ( ) .
    Here , is the right code.

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
    <html>
    <head>
    <title></title>
    <head/>
    <body style="backgrou nd-color: transparent">
    <?php
    $file=fopen("ne ws.txt","r") or exit("Unable to open file!");
    $first = 1;
    $ordn = fgetc($file);
    fgets($file);
    while (!feof($file))
    {
    if ($first = 1)
    {
    $check = fgetc($file);
    $first = 0;
    }
    if ($check = "_")
    {
    $check = fgetc($file);
    }
    if ($check = $ordn)
    {
    $ordn = $ordn - 1;
    while ($check(!"_"))
    {
    echo fgets($file);
    $check = fgetc($file);
    }
    }
    else
    {
    fgets($file);
    $check = fgetc($file);
    }
    }
    fclose($file);

    ?>
    </body>
    </html>
    This will work now.
    YOU TOO SCRIPTEE!

    NEXT TIME ENCLOSE YOUR CODE WITHIN PHP, CODE OR HTML TAGS!! READ THE POSTING GUIDLINES BEFORE POSTING ANYTHING IN THIS FORUM! - Ronald :cool:

    Comment

    • bovanshi
      New Member
      • Nov 2006
      • 2

      #3
      Thank you xD

      Comment

      • scriptee
        New Member
        • Nov 2006
        • 17

        #4
        Originally posted by bovanshi
        Thank you xD
        You are welcome :)

        Comment

        • jinapaia
          New Member
          • Feb 2007
          • 2

          #5
          i am getting similar parse error and i can't understand where exactly the sintax is wrong...can you help?
          the code is
          <?php
          require_once('d b_login.php');
          $sdbh = "";
          $expire = 900;
          function sess_open($save _path, $session_name){
          global $dbhost, $dbuser, $dbpasswd, $sdbh;
          if (! $sdbh = mysql_pconnect( $dbhost, $dbuser, $dbpasswd)){
          echo mysql_error();
          exit;
          }
          return true;
          }
          function sess_close(){
          return true;
          }
          function sess_read($key) {
          global $sdbh, $dbname, $tb_sessions;
          $query = "
          select
          data
          from
          $tb_sessions
          where
          id = '$key'
          and
          expire > UNIX_TIMESTAMP( )
          ";
          $result = mysql_query($qu ery);
          if($record = mysql_fetch_row ($result)){
          return $record;
          }else {
          print (mysql_error()) ;

          }
          function sess_write($key , $val){
          global $sdbh, $dbname, $tb_sessions, $expire;
          $value = addslashes($val );
          $query = "
          replace into
          $tb_sessions
          values (
          '$key',
          '$value',
          UNIX_TIMESTAMP( ) + $expire
          )
          ";
          $result = mysql_query($qu ery);
          echo mysql_error();
          return $result;
          }
          function sess_destroy($k ey){
          global $sdbh, $dbname, $tb_sessions;
          $query = "
          delete from
          $tb_sessions
          where
          id = '$key'
          ";
          $result = mysql_query($qu ery);
          return $result;
          }
          function sess_gc($maxlif etime){
          global $sdbh, $dbname, $tb_sessions;
          $query = "
          delete from
          $tb_sessions
          where
          expire < UNIX_TIMESTAMP( )
          ";
          $result = mysql_query($qu ery);
          return mysql_affected_ rows($sdbh);
          }
          session_set_sav e_handler("sess _open","sess_cl ose","sess_read ","sess_write", "sess_destroy", "sess_gc");
          session_start() ;
          $sn = session_name();
          $sid = session_id();

          ?>

          Comment

          Working...