Drupal doesn,t execute mysql_query() for specific table-name string

bill1821 - July 1, 2008 - 21:21
Project:Drupal
Version:5.7
Component:mysql database
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

I try to execute this very simple code:

<?php
....
$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.

#1

Damien Tournoud - July 1, 2008 - 22:47
Assigned to:bill1821» Anonymous
Status:active» active (needs more info)

Hum... 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.

#2

bill1821 - July 1, 2008 - 23:07

Of 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.

#3

bill1821 - July 1, 2008 - 23:22
Status:active (needs more info)» closed

Maybe has to do with the size of the Drupal scripts.

#4

gpk - July 2, 2008 - 07:31

Hmmmm 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/sour...) 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 ...

#5

Damien Tournoud - July 2, 2008 - 08:29

Another thing: are you using mysql and mysqli consistently? (ie. if you try mysql_query, are you also using mysql on Drupal?)

 
 

Drupal is a registered trademark of Dries Buytaert.