Closed (fixed)
Project:
Drupal core
Version:
5.7
Component:
mysql database
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
1 Jul 2008 at 21:21 UTC
Updated:
2 Jul 2008 at 08:29 UTC
I try to execute this very simple code:
....
$sql = 'SELECT field_regions_infrontpage_value FROM content_field_regions_infrontpage LIMIT 3';
$result_n = mysql_query($sql);
.....
and mysql_query yield 'false'.
1) I executed this query in a simple php script outside Drupal and I find no problem.
2) when I replace the query above with another query (with table-name with smaller string) inside Drupal there is no problem. After an extensive troubleshooting I found that the problem is that mysql_query() does not accept so long strings as table-name when the script is executed inside Drupal.
I must mention that the query is so simple because of the exhaustive troubleshooting (I was stripping my query) until I find why query is not executed.
Comments
Comment #1
damien tournoud commentedHum... What?
There are no reason why Drupal could interfere here. The problem is probably elsewhere.
Note that Drupal has an abstraction of mysql_query (in the form of db_query). But there is no reason the result could be different.
Comment #2
bill1821 commentedOf course I know about (db_query).
I cannot imagine why there is a difference when someone execute mysql_query() via Drupal in respect with an other php-script. In fact that is the most peculiar problem I have ever met in php.
Comment #3
bill1821 commentedMaybe has to do with the size of the Drupal scripts.
Comment #4
gpk commentedHmmmm I can see why you might be confused!
With a very simple query like that, if it is run via db_query() (see http://api.drupal.org/api/file/includes/database.mysql-common.inc/6/source) then your exact query should be passed on unchanged to _db_query() (see http://api.drupal.org/api/file/includes/database.mysql.inc/6/source) unchanged. The only material difference I can see there is that mysql is invoked via
$result = mysql_query($query, $active_db);where (global) $active_db is the MySQL connection. I can't see how this would account for the behaviour you experience though! (http://uk3.php.net/manual/en/function.mysql-query.php) The only other thing I can think is that there is a subtle typo in your query text, though I'm sure you've checked it 1,000 times ...Comment #5
damien tournoud commentedAnother thing: are you using mysql and mysqli consistently? (ie. if you try mysql_query, are you also using mysql on Drupal?)