Hi.
I'm getting this message when trying to access shoutbox settings page in Drupal 7:

PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'drupal.profile_fields' doesn't exist: SELECT name FROM {profile_fields} ORDER BY name ASC; Array ( ) en shoutbox_admin_settings() (line 82 of /var/www/SITE/sites/all/modules/shoutbox/shoutbox.pages.inc).

This is what I find in line 82 of shoutbox.pages.inc.

 // Generate choices for profile fields
   if (module_exists('profile')) {
    // TODO: Make this work in D7
    $choices = array();
    $fields = db_query("SELECT name FROM {profile_fields} ORDER BY name ASC");
    while ($field = db_fetch_object($fields)) {
      $choices[$field->name] = $field->name;
    }

Any idea?

Comments

taecelle’s picture

subscribe - same problem

taecelle’s picture

Any help??

Golem07’s picture

Very same problem here after an upgrade D6.22 to 7.10!

Golem07’s picture

Found the solution for my upgraded site:

I got suspicious when I noticed that the profile fields management on my upgraded site still looked exactly like in d6.

So I went to the modules section and simply disabled and uninstalled the core module "profile". Et voila! everything looked like it should look like on a D7 install again. Shoutbox admin interface is working now.

Didn't realize before that the "profile" module is not even listet on D7 modules page any more. Seems like a left-over from the D6 install. After uninstalling you won't even get the option to install it again.

Hope this helps!

taecelle’s picture

Found the solution
There are some errors in code, because the difference between drupal 6 and drupal 7.

That's how code must be:

// Generate choices for profile fields
   if (module_exists('profile')) {
    // TODO: Make this work in D7
    $choices = array();
    $fields = db_query("SELECT name FROM {profile_field} ORDER BY name ASC");
   foreach ($fields = $field) {
      $choices[$field->name] = $field->name;
    }

because in drupal 7 function db_fetch_object is removed, and in database there is no profile_fieldS, but there is profile_fileld.

snsace’s picture

subscribe

snsace’s picture

I tried fix in #5 but now get a white screen when accessing admin.

Disabling the core "Profile" module does work but the downside to that is you lose user's profile info they have set up in their accounts.

snsace’s picture

Status: Active » Needs work
farald’s picture

Unrelated to this module..but might be useful.
I got same error on update.php regarding profile.module.

Call Stack:
    0.0018     834688   1. {main}() /public_html/update.php:0
    0.2619   60056720   2. update_fix_compatibility() /public_html/update.php:430
    0.2624   60060256   3. update_check_incompatibility() /public_html/includes/update.inc:28
    0.2837   58465152   4. system_rebuild_module_data() /public_html/includes/update.inc:52
    0.2837   58465616   5. _system_rebuild_module_data() /public_html/modules/system/system.module:2429
    0.3966   58930472   6. drupal_alter() /public_html/modules/system/system.module:2401
    0.3967   58930688   7. user_system_info_alter() /public_html/includes/module.inc:1018
    0.3967   58930832   8. db_table_exists() /public_html/modules/user/user.module:3936
    0.3967   58930832   9. DatabaseSchema_mysql->tableExists() /public_html/includes/database/database.inc:2732
    0.3967   58931152  10. DatabaseConnection_mysql->queryRange() /public_html/includes/database/mysql/schema.inc:502
    0.3967   58931952  11. DatabaseConnection->query() /public_html/includes/database/mysql/database.inc:84
    0.3968   58935064  12. DatabaseStatementBase->execute() /public_html/includes/database/database.inc:664
    0.3968   58935144  13. PDOStatement->execute() /public_html/includes/database/database.inc:2139

It tries to find out whether or not a table exists in user.module, here:

<?php
function user_system_info_alter(&$info, $file, $type) {
  if ($type == 'module' && $file->name == 'profile' && db_table_exists('profile_field')) {
    $info['hidden'] = FALSE;
  }
};?>

But then db_table_exists panics. Sure this isn't a core related fault?
I ended up installing profile.module and then disabling it to overcome the issue.

Arjean-1’s picture

Thanks to taecelle #5 I could make it work.
Only in the foreach loop the "=" had to be "as".
So my code becomes:

file:shoutbox.pages.inc (row 79)

// Generate choices for profile fields
if (module_exists('profile')) {
	// TODO: Make this work in D7
	$choices = array();
	$fields = db_query("SELECT name FROM {profile_field} ORDER BY name ASC");
	foreach ($fields as $field) {
		$choices[$field->name] = $field->name;
	}

When selecting an option in the shoutbox settings from the "Use profile field for user name" the front page crashed,
so had to change the following too:
file:shoutbox.module (row 334)

if ($field = variable_get('shoutbox_profile_name', '')) {
	$name = db_query("
		SELECT v.value FROM {profile_value} v INNER JOIN {profile_field} f ON v.fid = f.fid
		WHERE f.name = :name AND v.uid = :uid", array(':name' => $field, ':uid' => $shout->uid))->fetchField();
		$shout->nick = $name ? $name : $shout->nick;
	}

That made it all work for me.

Oleksa-1’s picture

Version: 7.x-1.0-alpha2 » 7.x-1.x-dev
Category: support » bug
Priority: Normal » Major
Status: Needs work » Reviewed & tested by the community

thx

plazik’s picture

Thanks Arjean.
#10 works for me.

noctifer’s picture

#10 works like a charm

noctifer’s picture

Issue summary: View changes

Beautiful. Thank you.

vitalblue’s picture

Hi to all,
I tested the code above and applied to the module. Thank anyone for your help.
I took a further look for profile module in Drupal7 and I found that is deprecated. https://drupal.org/node/874026
So as profile module is deprecated I manage to include any field, text type, that will be added to user
Admin-Configuration-People-Account settings-Manage fields

I had in mind to include Profile2 but I'm not sure if this is needed now or not.

Please get latest 7.x-1.x-dev version to check.

Thanks a lot.

vitalblue’s picture

Assigned: Unassigned » vitalblue
Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.