Parse Errors are causing me a problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jecha
    New Member
    • Feb 2007
    • 3

    Parse Errors are causing me a problem

    I don't know why I continue getting such errors .With this one I can't even locate where the problem is.Its a database class for accessing information from a website database.[php]
    <?
    /**
    * Database.php
    */
    include("consta nts.php");
    include("db_con n.php");

    class Users
    {
    var $connection; //The MySQL database connection
    var $num_active_use rs; //Number of active users viewing site
    var $num_active_gue sts; //Number of active guests viewing site
    var $num_members; //Number of signed-up users
    /* Note: call getNumMembers() to access $num_members! */

    /* Class constructor */
    function Users(){
    /* Make connection to database */
    $this->connection = mysql_connect(' localhost', 'root', 'password') or die(mysql_error ())
    mysql_select_db (Users, $this->connection) or die(mysql_error ());

    /**
    * Only query database to find out number of members
    * when getNumMembers() is called for the first time,
    * until then, default value set.
    */
    $this->num_members = -1;

    if(TRACK_VISITO RS){
    /* Calculate number of users at site */
    $this->calcNumActiveU sers();

    /* Calculate number of guests at site */
    $this->calcNumActiveG uests();
    }
    }
    [/php]
    Now the error is :Parse error: parse error, unexpected T_STRING in c:\inetpub\wwwr oot\croco\tserv er\login system v.2.0\include\d atabase.php on line 25
    where line 25 is: mysql_select_db (Users, $this->connection) or die(mysql_error ());

    Please help me I'm tired of this and I need to move on
    Thank you in advance
    jecha
    Last edited by ronverdonk; Feb 23 '07, 02:38 PM. Reason: code within tags
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    I am also tired, but mainly of members who do not enclose their code within php or code tags and make it real hard to read their code!

    Before you post any further read the Posting Guidelines at the top of this forum!
    And especially the part about enclosing your code within tags.

    moderator

    Comment

    • ronverdonk
      Recognized Expert Specialist
      • Jul 2006
      • 4259

      #3
      These 2 consecutive statements will result in parse errors:

      Statement 1:
      [php]
      $this->connection = mysql_connect(' localhost', 'root', 'password') or die(mysql_error ())
      [/php]
      You must end a PHP statement with a semi column.

      Statement 2:
      [php]mysql_select_db (Users, $this->connection) or die(mysql_error ());[/php]
      Users is neither a variable nor a literal. You must code any of them here, so it is either $Users or "Users".

      Ronald :cool:

      Comment

      Working...