This question is similar to this one: Why does mysql_query() return TRUE with a SELECT statement?. I execute a SELECT mysql query in php, but it returns true. I've been starting at it for half an hour now and I'm completely positive it is a select query and it returns true. The obvious fix for the similar question was to check if the connection was still alive. The difference for me is, the mysql_error is empty. Here are the parts of my code that cause the error:
public function query($query, $params = array())
{
$params['prefix'] = 'unpirate_';
foreach($params as $key => $param)
{
$query = str_replace('{' . $key . '}',
mysql_real_escape_string($param), $query);
}
echo($query);
return mysql_query($query, $this->conn) or $this->error($query);
}
public function fetch_all($query, $params = array())
{
$result = $this->query($query, $params);
if($result === true)
die('"' . mysql_error() . '"');
(...)
}
The query that is echo'd is a valid query (SELECT * FROM [table] WHERE event_id = "54") and the only other thing that is echo'd is "", thus the result is true and the mysql_error is empty. Do you guys have any idea what is going on? Please correct me if my conclusion is not right.
PHP version: PHP 5.3.10-1ubuntu3.2 with Suhosin-Patch (cli) (built: Jun 13 2012 17:19:58)
MySQL version: mysql Ver 14.14 Distrib 5.5.24, for debian-linux-gnu (x86_64) using readline 6.2