Problem with PHP code

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
sharad2802
Forum Newbie
Posts: 2
Joined: Thu Oct 10, 2013 4:47 am

Problem with PHP code

Post 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?
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Problem with PHP code

Post 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.
Post Reply