Appears to be correct. Without your code it will be hard to tell. Do you check for errors (mysql_error()) ?
pritaeas
Posting Prodigy
9,313 posts since Jul 2006
Reputation Points: 1,178
Solved Threads: 1,465
Skill Endorsements: 86
Damn, wonder how I could've missed this ... +1
pritaeas
Posting Prodigy
9,313 posts since Jul 2006
Reputation Points: 1,178
Solved Threads: 1,465
Skill Endorsements: 86
Golly I see loads of glitches in the code. Well their not exactly bugs since their not syntax errors but things that should be changed. Perhaps try the following:
class DB {
private $connection;
public function __construct(){
$this->connection = mysql_connect('localhost', 'user', 'pass', true) or die(mysql_error());
mysql_select_db( 'dbname', $this->connection ) or die(mysql_error());
}
public function exec_query( $query ) {
$v=mysql_query($query, $this->connection ) or die(mysql_error());
return $v;
}
}
As you can see I added 'true' into the connect function, added a return statement into the exec_query() function and added debugging information in several places. Below is an example for using your class in case it was miss-used.
$con=new DB();
$result=$con->exec_query('SELECT * FROM `table`');
while ($row=mysql_fetch_assoc($result)) {
//loop through result here
}
cwarn23
Occupation: Genius
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 260
Skill Endorsements: 13