Problems with mysql_fetch_array

jk@arsum.com - July 8, 2009 - 17:47
Project:Invitation Voucher
Version:5.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

In function invvoucher_validate:
For some i have empty results with with $r = mysql_fetch_array

I had to change to db_fetch_array. This works for me

function invvoucher_validate($code) {
  $r = db_fetch_array(db_query("SELECT * FROM {invvoucher} WHERE code = '%s'", $code));
  if (!empty($r)) {
    if ($r['date_exp'] < time()) {// exp_date
      form_set_error('invvoucher_response', t('The code you entered has expired.'));
      return 0;
    }
    if ($r['reg_count'] == 0) { //quantity
      form_set_error('invvoucher_response', t('The code you entered can be used no more.'));
      return 0;
    }
    if ($r['code'] == $code) {
      return 1;
    }
  }
  form_set_error('invvoucher_response', t('The code you entered is incorrect.'));
  return 0;
}

#1

dear_anton - July 12, 2009 - 18:55

Nice!
I'll check it as soon as possible :)

Great thanks!

 
 

Drupal is a registered trademark of Dries Buytaert.