PHP MySQL error on valid query

I’m getting an error in PHP on a valid query, which executes fine when run directly from PHPMyAdmin.

Has anyone had a similar problem before and could point me in the right direction?

The error is below along with the function used the execute the query.

Array
(
    [Error] => Invalid Query : SELECT * FROM users ORDER BY userDeleted ASC, userFullname ASC
)
Array
(
    [Error] => Empty MySQL resource.
)

public function query($q){
		if(empty($q)) $this->dbError('Empty MySQL Query.');
		if($this->linkID == 0) $this->connect();
		$temp = @mysql_query($q, $this->linkID);
		if(!$temp) $this->dbError('Invalid Query : '.mysql_error().'<br />'.$q);
		return $temp;

}

public function getUsers(){
	$q = "SELECT * FROM users ORDER BY userDeleted ASC, userFullname ASC";
	$result = $this->query($q);

Cheers,
Rhys

Try this:



 $temp = @mysql_query($q); 


//

Thanks but that didn’t solve it. The strange thing is, this system works. It works on other sites and works here in some instances. I can log in, but I can’t select from a certain table. Strange and something I’ve not seen before.

The error returned states that you do not have a valid MySql connection.


//  [Error] => Empty MySQL resource. 


// try to connect	 to database using username and password
   $dbh = @ mysql_connect
  (
    $hostname,
    $username,
    $password
  );
  if(mysql_error())	
    echo __LINE__,	mysql_error();				
	
	
// try to select database
   $connected = @ mysql_select_db ($database);
   if (mysql_error()) 
     echo __LINE__,	mysql_error();	


//

First of all avoid suppressing the warnings by using ‘@’.

Can you post the whole class and/or the area of code where you have made the mysql server connection?