Jump to content

Archived

This topic is now archived and is closed to further replies.

crouchjay

parse error

Recommended Posts

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
}
}

Share this post


Link to post
Share on other sites
Are you running PHP5? That code will not work in PHP4 because classes in PHP4 don't recognize private vs. public.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.