Ignore:
Timestamp:
Mar 17, 2013, 3:55:39 PM (11 years ago)
Author:
mistic100
Message:

replace mysql_* by pwg_db_* and correct errors inherited by mysql return values

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/event_cats/include/evntcats_admin_funcs.inc.php

    r10457 r21652  
    7979  $page['errors'][] =
    8080   sprintf(l10n('ec_DB_problem'), $n).
    81    'MySQL error '.mysql_errno().', "'.mysql_error().'"';
     81   'MySQL error '.pwg_db_errno().', "'.pwg_db_error().'"';
    8282  return false;
    8383}
     
    137137    $t2 = 0; $t3 = false; $t4 = false;
    138138    while ( // The check is executed once at minimum
    139       !($t3 = mysql_fetch_row(pwg_query("
     139      !($t3 = pwg_db_fetch_row(pwg_query("
    140140        SELECT `id`
    141141        FROM `".GROUPS_TABLE."`
     
    154154     $page['errors'][] =
    155155      sprintf(l10n('ec_group_create_pb'), $_POST['groupname']).' (1) : '.
    156       'MySQL error '.mysql_errno().', "'.mysql_error().'"';
     156      'MySQL error '.pwg_db_errno().', "'.pwg_db_error().'"';
    157157    if (
    158158      pwg_query("
     
    162162    ) $page['errors'][] =
    163163      sprintf(l10n('ec_group_create_pb'), $_POST['groupname']).' (2) : '.
    164       'MySQL error '.mysql_errno().', "'.mysql_error().'"';
     164      'MySQL error '.pwg_db_errno().', "'.pwg_db_error().'"';
    165165    else $page['infos'][] = sprintf(
    166166      l10n('ec_group_create_OK2'),
     
    176176      array_key_exists($_POST['ec_in_up_cat'], $ec_lists['categories'])
    177177    ) {
    178       if (mysql_num_rows(pwg_query("
     178      if (pwg_db_num_rows(pwg_query("
    179179        SELECT `id`
    180180        FROM `".CATEGORIES_TABLE."`
     
    197197         );
    198198        mass_inserts(GROUP_ACCESS_TABLE,array('group_id','cat_id'), $inserts);
    199         if (mysql_errno() == 0)
     199        if (pwg_db_errno() == 0)
    200200         $page['infos'][] = sprintf(
    201201           l10n('ec_group_create_OK2'),
     
    206206          l10n('ec_assoc_pb'),
    207207          $_POST['groupname'],$ec_lists['categories'][$_POST['ec_in_up_cat']]
    208          ).' : MySQL error '.mysql_errno().', "'.mysql_error().'"';
     208         ).' : MySQL error '.pwg_db_errno().', "'.pwg_db_error().'"';
    209209      }
    210210    }
     
    241241          l10n('ec_assoc_pb'),
    242242          $_POST['groupname'],$ec_lists['add_pages'][$_POST['ec_in_up_aps']]
    243          ).' : MySQL error '.mysql_errno().', "'.mysql_error().'"';
     243         ).' : MySQL error '.pwg_db_errno().', "'.pwg_db_error().'"';
    244244        else $page['infos'][] = sprintf(
    245245         l10n('ec_group_create_OK2'),
     
    274274          AND `user_id` = '$ec_user_id';
    275275      ");
    276       while ($row = mysql_fetch_array($result))
     276      while ($row = pwg_db_fetch_assoc($result))
    277277       $granteds[$row['cat_id']][] = $row['user_id'];
    278278      $inserts = array();
     
    285285      if (count($inserts) != 0) {
    286286        mass_inserts(USER_ACCESS_TABLE, array('user_id','cat_id'), $inserts);
    287         if (mysql_errno() == 0)
     287        if (pwg_db_errno() == 0)
    288288         $page['infos'][] = sprintf(
    289289           l10n('ec_group_create_OK2'),
     
    294294          l10n('ec_assoc_pb'),
    295295          $_POST['login'], $ec_lists['categories'][$_POST['ec_in_up_cat']]
    296          ).' : MySQL error '.mysql_errno().', "'.mysql_error().'"';
     296         ).' : MySQL error '.pwg_db_errno().', "'.pwg_db_error().'"';
    297297      }
    298298    }
     
    553553  $arg2p = ($arg2 == 'NULL') ? 'IS NULL' : ' = '.$arg2;
    554554  $ec_user_idp = ($ec_user_id == 'NULL') ? 'IS NULL' : ' = '.$ec_user_id;
    555   if (($t1 = mysql_fetch_row(pwg_query("
     555  $r = pwg_query("
    556556    SELECT `id`
    557557    FROM `".EVNTCATS_TABLE."`
     
    563563      AND `forced`  = '".$forced."'
    564564      AND `comment` = '".$comment."'
    565   "))) !== false) { // print("<pre>$arg1 $arg2<br>$q</pre>");
     565  ");
     566  if (pwg_db_num_rows($r)) { // print("<pre>$arg1 $arg2<br>$q</pre>");
     567    $t1 = pwg_db_fetch_row();
    566568    $page['errors'][] = sprintf(l10n('ec_entry_already_exists'), $t1[0]);
    567569    return false;
     
    570572  // Delete other entries using the same code, if needed
    571573  if ($del_other) {
    572     if ((
    573       $t1 = mysql_fetch_row(pwg_query("
    574         SELECT `code`
    575         FROM `".EVNTCATS_TABLE."`
    576         WHERE `id` = ".$_POST['ec_entry_sel']
    577       ))) === false
    578     ) die('Entry not found in DB ?!');
     574    $r = pwg_query("
     575      SELECT `code`
     576      FROM `".EVNTCATS_TABLE."`
     577      WHERE `id` = ".$_POST['ec_entry_sel']
     578    );
     579    if (!pwg_db_num_rows($r)) die('Entry not found in DB ?!');
     580    $t1 = pwg_db_fetch_row($r);
    579581    $r = pwg_query("
    580582      SELECT `id`
     
    583585       AND `id` <> ".$_POST['ec_entry_sel']
    584586    );
    585     while ($t2 = mysql_fetch_row($r)) if (!ec_delete_entry_OK($t2[0]))
     587    while ($t2 = pwg_db_fetch_row($r)) if (!ec_delete_entry_OK($t2[0]))
    586588     return false;
    587589  }
     
    608610      $page['errors'][] =
    609611       l10n('ec_entry_create_pb').' : '.
    610        'MySQL error '.mysql_errno().', "'.mysql_error().'"'
     612       'MySQL error '.pwg_db_errno().', "'.pwg_db_error().'"'
    611613      ;
    612614      $ret = false;
     
    616618      $forced = ($forced == 'false') ? '' : l10n('ec_cnfrm_forced');
    617619      $page['infos'][] =
    618        sprintf(l10n('ec_entry_create_OK'), mysql_insert_id()).
     620       sprintf(l10n('ec_entry_create_OK'), pwg_db_insert_id()).
    619621       $ec_code.' => '.
    620622       $ec_lists['user_ids'][$ec_user_id].$forced
     
    639641      $page['errors'][] =
    640642       l10n('ec_entry_create_pb').' : '.
    641        'MySQL error '.mysql_errno().', "'.mysql_error().'"'
     643       'MySQL error '.pwg_db_errno().', "'.pwg_db_error().'"'
    642644      ;
    643645      $ret = false;
     
    662664function ec_delete_entry_OK($ec_id) {
    663665  global $page;
    664   if (count($t = mysql_fetch_row(pwg_query("
     666  $r = pwg_query("
    665667    SELECT `code`
    666668    FROM `".EVNTCATS_TABLE."`
    667669    WHERE `id` = $ec_id;
    668   "))) == 0) {
     670  ");
     671  if (!pwg_db_num_rows($r)) {
    669672    $page['errors'][] = sprintf(l10n('ec_entry_dont_exist'), $ec_id);
    670673    return false;
    671674  }
     675  $t = pwg_db_fetch_row($r);
    672676  if (pwg_query("
    673677    DELETE FROM `".EVNTCATS_TABLE."`
     
    677681     sprintf(l10n('ec_entry_del_nok'),
    678682     $ec_id).
    679      'MySQL error '.mysql_errno().', "'.mysql_error().'"';
     683     'MySQL error '.pwg_db_errno().', "'.pwg_db_error().'"';
    680684    return false;
    681685  }
Note: See TracChangeset for help on using the changeset viewer.