Page 1 of 1

Problem with PHP code

Posted: Fri Oct 25, 2013 4:11 am
by sharad2802
here is my code its not working , it showing this error :
PHP Parse error: syntax error, unexpected ';', expecting T_FUNCTION in connectionManager.php on line 35

Code: Select all

 
<?php
class MySQL {

   var $server;
   var $username;
   var $password;
   var $db_name;
   var $qry_result;

   /* 
      Constructor. Sets the values for the database.

      @param $server    - Server Name (Usually localhost)
      @param $username  - Database Access Username
      @param $password  - User Password
   */    
    
   function __construct($server, $username, $password, $db_name) {
      $this->server = $server;
      $this->username = $username;
      $this->password = $password;
      $this->db_name = $db_name;
        
      //Connect to the database
         $this->connect();
   }
    
   /* 
      Connects the system to the given database.
   */
   function connect() {
      mysqli_connect($this->server, $this->username, $this->password) or die(mysql_error());
      mysqli_select_db($this->db_name) or die(mysql_error());
  }
?> ----------------------------------------------------35th line.
Whats wrong with this code?

Re: Problem with PHP code

Posted: Fri Oct 25, 2013 6:15 am
by Celauran
What's wrong? You're using var. You're using die(). You also appear to be trying to add an i to mysql_ functions and expecting them to work. mysqli_connect takes four parameters. Better still, use the constructor. mysqli_select_db doesn't exist.