Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8200669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:31:48+00:00 2026-06-07T06:31:48+00:00

The perfect little module for what I am looking to do was made for

  • 0

The perfect little module for what I am looking to do was made for drupal 6 but to my dismay it doesn’t work on drupal 7. I’ve have learned that drupal 7 has a new api for the database. I have tried to get it to work but I am admittedly out of my league here. I am hoping some one could give me a little guidance. Specifically with the db_query.

function webform_image_validation_webform_validation_validate($validator_name, $items,   
$components, $rule) {
$errors = array();
if ($items) {
switch ($validator_name) {
  case 'max_image_size':
    $dimensions = explode('x', $rule['data']);
    foreach ($items as $key => $val) {
      if (is_numeric($val['_fid'])) {
        $result = db_query("select * from {files} where fid = %d", $val['_fid']);
        while ($data = db_fetch_object($result)) {
          $thefile = $data;
        }
        $image_info = image_get_info($thefile->filepath);
        if (webform_image_validation_validate_image($image_info, $dimensions[0], $dimensions[1], FALSE) === FALSE) {
          $errors[$key] = t('Your image did not match the required width and/or height. (') . $dimensions[0] . t(' x ') . $dimensions[1] . t(')');
        }
      }
    }

This is the error I receive.

Argument 2 passed to db_query() must be an array, string given, called in
/home/designco/public_html/dev/sites/all/modules/webform_image_validation/
webform_image_validation.module on line 69 and defined in
/home/designco/public_html/dev/includes/database/database.inc on line 2310

It appears I need to add an array but I get lost there. Any help would be appreciated. I’m just trying to find out if I’m the right track.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T06:31:49+00:00Added an answer on June 7, 2026 at 6:31 am

    db_query works differently in Drupal7.

    
    $result = db_query("select * from {files} where fid = %d", $val['_fid']);
    while ($data = db_fetch_object($result)) {
      $thefile = $data;
    }
    


    becomes

    
    


    $results = db_query("select * from {files} where fid = :fid", array(':fid' => $val['_fid']));
    foreach($results as $result) {
    // Do your thing for each result.
    }

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

a little question. I have this code, which is works perfect for files, but
I am looking for a little bit of help with jqGrid. I have a
I have a sort of vague question that you guys are perfect for answering.
I have this little crazy method that converts BigDecimal values into nice and readable
I'm so close to getting this effect perfect, but I have run into a
I am working first time on drupal and I have a little problem with
I have an awesome little function that looks like this: def verbose_print(message, *args, **kwargs):
This seems to make perfect sense, but it is not working. I seem to
Everything before was perfect... but... Today something happened to my License checker (without touching
This Slide show is running perfect with image and text at same time, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.