This forum is for module development and code related questions, not general module support. For general support, use the Post installation forum.

i18n error on Drupal 4.7

I installed and enabled the international module (i18n) in Drupal 4.7.2, but got the following error message:

user warning: Column 'nid' in field list is ambiguous query: SELECT nid FROM node n LEFT JOIN i18n_node i18n ON n.nid = i18n.nid WHERE (i18n.language ='zh-hant' OR i18n.language ='' OR i18n.language IS NULL) AND n.type='audio' AND n.status=1 ORDER BY changed DESC LIMIT 0, 1 in /(drupal root directory)/includes/database.mysql.inc on line 120.

It appears i18n cannot use the same name {nid} when the table is created.

Is there any solution to this? Thanks!

Block users by IP

Hello guys,

Is there any mod available to block spamming users or specific users by IP?

Help needed with Forms and interacting with the database

I am trying to add some functionality to the organic groups module. I wish to be able to add or remove users to og's from the user edit pages. I have created a form using the below code which shows which groups the user is a member of however I am stuck when trying to get the values from the check boxes and adding the values to the database.

This is the code that displays the checkboxes with appropriate names and displays whether the user is currently a member. I have tried a few different values for the return value (to update the database in different ways).

case 'form':
$result_og = db_query("SELECT title, nid FROM node WHERE type = 'og'");
if (user_access('administer organic groups')) {
while ($field = db_fetch_object($result_og)) {
if (!isset($fields['ogGroups'])) {
$fields['ogGroups'] = array('#type' => 'fieldset', '#title' => ogGroups, '#weight' => $w++);
}
$result_user = db_query("SELECT nid FROM og_uid WHERE $account->uid = uid && $field->nid = nid");
$chkbx_checked = 0;
while ($field_user = db_fetch_object($result_user)) {
if ($field_user->nid == $field->nid) {
$chkbx_checked = 1;
break;
}
}
$fields['ogGroups'][$field->title] = array('#type' => 'checkbox',
'#title' => $field->title,
'#default_value' => $chkbx_checked,
'#return_value' => 1,
);
}
}
return $fields;

Ajax image uploader

Hi everyone,

i'm looking to add the the new ajax upload facility [in upload.module i think] to the image.module to give users some indication of how long their upload will take.

I've not had chance to look at the code in upload.module so i was wondering if anyone else had had a go at this??

cheers
Tom

form_submit not updating the database

I'm in the process of learning how to create a custom Drupal module, and have hit a snag with a database update.

My issue is in the form_submit hook. This is getting fired for the Insert, and my inserts are working fine. However, something is going wrong with the updates, but my troubleshooting code is not firing so I'm really having a hard time tracking this down. Here's the function in question:


function issues_project_submit($form_id, $form_values) {
global $user;
$start = NULL;
$end = NULL;

//preprocess the dates if needed
if (!empty($form_values['startdate'])) {
$start = strtotime($form_values['startdate']);
}
if (!empty($form_values['enddate'])) {
$end = strtotime($form_values['enddate']);
}

//For troubleshooting
watchdog('debugging', 'in submit');

if ($form_values['projectid'] == 0) {
$id = db_next_id('issues_projects');

$sql = 'insert issues_projects (';
$sql .= 'project_id, project_name, start_date, end_date, created_by, created_on) values (';
$sql .= $id .', ';
$sql .= "'". check_plain($form_values['projectname']) ."', ";

if ($start) {
$sql .= "'". date('Y-m-d', $start) ."', ";
}
else {
$sql .= "null, ";
}

if ($end) {
$sql .= "'". date('Y-m-d', $end) ."', ";
}
else {
$sql .= "null, ";
}

$sql .= $user->uid .", ";
$sql .= "'". date('Y-m-d') ."' ";
$sql .= ');';

Place Simplenews Block on Page

I have Drupal 4.7 with Simplenews. Module seems to be working fine. I would like to place the Simplenews block on a regular page (node) so I can point users directly to the page to signup.

I did a search of forums and found this code used to place a block within a page:

Pages

Subscribe with RSS Subscribe to RSS - Module development and code questions