Jump to content


Photo

parse error


  • Please log in to reply
2 replies to this topic

#1 crouchjay

crouchjay
  • Members
  • PipPip
  • Member
  • 26 posts

Posted 13 May 2006 - 03:21 PM

The following is the code. I keep getting a
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/crouchja/public_html/mysql.class.php on line 5.

<?php

class mysql {

**I am assuming this is line 5--> private $linkID; //MySQL link identifier
private $host; //MySQL server host
private $user; //MySQL user
private $pswd; //MySQL password
private $db; //MySQL database
private $result; //Query result
private $querycount; //Total queries executed

/* Class constuctor. Initializes the $host, $user, $pswd and $db fields. */
function mysql($host, $user, $pswd, $db)
{
$this->host = $host;
$this->user = $user;
$this->pswd= $pswd;
$this->db = $db;
}//End of mysql constuctor

/*Connects to the MySQL database server. */
function connect()
{
try {
$this->linkID = @mysql_connect($this->host,$this->user,$this->pswd);
if (! $this->linkID)
throw new Exception ("Could not connect to the database server1.");
}//End of try
catch (Exception $e) {
die ($e->getMessage());
}//End of catch
}

/* Selects the MySQL database. */
function select()
{
try {
if (! @mysql_select_db($this->db, $this->linkID))
throw new Exception("Could not connect to the database server2.");
}//end of try
catch (Exception $e) {
die ($e->getMessage());
}//end of catch
}
}

#2 _will

_will
  • Members
  • PipPip
  • Member
  • 25 posts

Posted 14 May 2006 - 04:57 AM

Are you running PHP5? That code will not work in PHP4 because classes in PHP4 don't recognize private vs. public.

#3 crouchjay

crouchjay
  • Members
  • PipPip
  • Member
  • 26 posts

Posted 16 May 2006 - 06:18 AM

Thank you. Cleared up the problem.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users