Hi,
this is put into a block code text box, with php code filter applied. Here is the whole block code:
<?php global $user; $result=db_query("SELECT content_type_nodeprofile.field_country_value, users_1.name, users_1.uid FROM ((users INNER JOIN content_type_nodeprofile ON users.uid = content_type_nodeprofile.field_uid_value) INNER JOIN content_type_nodeprofile AS content_type_nodeprofile_1 ON content_type_nodeprofile.field_country_value = content_type_nodeprofile_1.field_country_value) INNER JOIN users AS users_1 ON content_type_nodeprofile_1.field_uid_value = users_1.uid WHERE (((users.uid)=$user->uid) AND ((users_1.uid)<>$user->uid)) ORDER BY users_1.uid DESC LIMIT 5; "); while ($u = db_fetch_object($result)) { $items[]="<li class=\"member-list\">"; $items[]="<a class=\"members-link\" href=\"user/$u->uid\">$u->name</a>"; $items[]=" <a href=\"/search/user-search?filter1=$u->field_country_value\" class=\"geo-link\">$u->field_country_value</a>"; $items[]="</li>"; } return theme('front_page_geo_blocks', $items, "From my country"); ?>
is the problem the ordering of my filters for the php filter? Where would I need to place the html_entity_decode() to prevent the code getting mangled? I don't understand how the blocks are performing as per design if the code is getting altered? :-S
Thanks
Neil
----- Original Message ----- From: "Saint-Genest Gwenael" gwenael.saint-genest@makina-corpus.com To: support@drupal.org Sent: Friday, June 06, 2008 6:07 PM Subject: Re: [support] Block php errors from Drupal Logs
Hi,
Where this SQL request is defined ?
According to php error you have an HTML encoding of the SQL string sent to mysql (' for "'" ... < for "<" ...). You must decode string before use with something like html_entity_decode();
Gwen
Neil: esl-lounge.com wrote:
I have some front page blocks based on nodeprofile fields which seem to be working fine and returning expected results. However my drupal logs are filling up with php errors on every view of the front page.
The original sql block code is:
SELECT content_type_nodeprofile.field_country_value, users_1.name, users_1.uid FROM ((users INNER JOIN content_type_nodeprofile ON users.uid = content_type_nodeprofile.field_uid_value) INNER JOIN content_type_nodeprofile AS content_type_nodeprofile_1 ON content_type_nodeprofile.field_country_value = content_type_nodeprofile_1.field_country_value) INNER JOIN users AS users_1 ON content_type_nodeprofile_1.field_uid_value = users_1.uid WHERE (((users.uid)=$user->uid) AND ((users_1.uid)<>$user->uid)) ORDER BY users_1.uid DESC LIMIT 5
whereas the php error log messages are like this:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') AND ((users_1.uid)<>)) ORDER BY users_1.uid DESC LIMIT 3' at line 3 query: SELECT content_type_nodeprofile.field_country_value, users_1.name, users_1.uid FROM ((users INNER JOIN content_type_nodeprofile ON users.uid = content_type_nodeprofile.field_uid_value) INNER JOIN content_type_nodeprofile AS content_type_nodeprofile_1 ON content_type_nodeprofile.field_country_value = content_type_nodeprofile_1.field_country_value) INNER JOIN users AS users_1 ON content_type_nodeprofile_1.field_uid_value = users_1.uid WHERE (((users.uid)=) AND ((users_1.uid)<>)) ORDER BY users_1.uid DESC LIMIT 3; in /home/mysite/public_html/includes/database.mysql.inc on line 172.
as you can see, the WHERE part of the query is being mangled. What could cause this? As I say, the blocks seem to be working perfectly so I don't get why the php errors are filling out my log files and why the WHERE part of the query is getting altered.
Regards
Neil