Skip to main content
Inspiring
September 5, 2013
Question

Trouble with detecting database since upgrading to CC

  • September 5, 2013
  • 1 reply
  • 1229 views

Hi,

Hope someone can help me here. I recently updated to DW CC and now I'm having all sorts of problems with some of my php pages. I have a membership database built where we show active membership and lapsed membership. I tried to build a page with a "lapsedmembers_2013" recordset based on the "lapsedmembers_2012" recordset, by simply updating the recordset to read records from 2013 only. When I tried doing what I've done for years, which is use DW's search and replace function to replace all dynamic text from 2012 to 2013, the first problem is that even though I chose "replace all" and then closed the dialog box, upon reopening, the recordset still says 2012. So, I thought maybe there's a bug in this recordset, so I deleted it from the server behaviors dialog box and rebuilt the recordset. Now it works locally. But upon uploading it to my Web site, I get the error message "No database selected." This isn't true because in each case of my coding for dynamic text, it clearly shows my database selected.

I'm baffled by this as I've never had this much difficulty "reusing" recordsets before. If I have to completely rebuild the page, that's fine, but why is it not seeing my database at all?

Thanks for any help you can send my way,

Gail

This topic has been closed for replies.

1 reply

Participating Frequently
September 6, 2013

>but why is it not seeing my database at all?

Can't tell without seeing the code.

Inspiring
September 6, 2013

Sorry, I neglected to post the code. Here it is. One thing I noticed here, is that the $query_lapsed2013 set of commands is duplicated multiple times, even though I believe I deleted the old recordset correctly (hit the 'minus' sign in the server behaviors dialog box). Is this causing a problem?

----------------------

<?php require_once('Connections/GCSMembership.php'); ?>

<?php

if (!isset($_SESSION)) {

  session_start();

}

$MM_authorizedUsers = "y";

$MM_donotCheckaccess = "false";

// *** Restrict Access To Page: Grant or deny access to this page

function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {

  // For security, start by assuming the visitor is NOT authorized.

  $isValid = False;

  // When a visitor has logged into this site, the Session variable MM_Username set equal to their username.

  // Therefore, we know that a user is NOT logged in if that Session variable is blank.

  if (!empty($UserName)) {

    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login.

    // Parse the strings into arrays.

    $arrUsers = Explode(",", $strUsers);

    $arrGroups = Explode(",", $strGroups);

    if (in_array($UserName, $arrUsers)) {

      $isValid = true;

    }

    // Or, you may restrict access to only certain users based on their username.

    if (in_array($UserGroup, $arrGroups)) {

      $isValid = true;

    }

    if (($strUsers == "") && false) {

      $isValid = true;

    }

  }

  return $isValid;

}

$MM_restrictGoTo = "admin_login.php";

if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {  

  $MM_qsChar = "?";

  $MM_referrer = $_SERVER['PHP_SELF'];

  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";

  if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)

  $MM_referrer .= "?" . $QUERY_STRING;

  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);

  header("Location: ". $MM_restrictGoTo);

  exit;

}

?>

<?php

if (!function_exists("GetSQLValueString")) {

function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")

{

  if (PHP_VERSION < 6) {

    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {

    case "text":

      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

      break;   

    case "long":

    case "int":

      $theValue = ($theValue != "") ? intval($theValue) : "NULL";

      break;

    case "double":

      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";

      break;

    case "date":

      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

      break;

    case "defined":

      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;

      break;

  }

  return $theValue;

}

}

$query_lapsed2013 = "SELECT user_id, lastname, firstname, middlename, dateremoved, year_removed FROM users WHERE year_removed = 2013 AND users.activity_status = 'n' ORDER BY dateremoved ASC, users.lastname";

$lapsed2013 = mysql_query($query_lapsed2013, $GCSMembership) or die(mysql_error());

$row_lapsed2013 = mysql_fetch_assoc($lapsed2013);

$totalRows_lapsed2013 = mysql_num_rows($lapsed2013);

$query_lapsed2013 = "SELECT user_id, lastname, firstname, middlename, dateremoved, year_removed FROM users WHERE year_removed = 2013 AND users.activity_status = 'n' ORDER BY dateremoved ASC, users.lastname";

$lapsed2013 = mysql_query($query_lapsed2013, $GCSMembership) or die(mysql_error());

$row_lapsed2013 = mysql_fetch_assoc($lapsed2013);

$totalRows_lapsed2013 = mysql_num_rows($lapsed2013);

$query_lapsed2013 = "SELECT user_id, lastname, firstname, middlename, dateremoved, year_removed FROM users WHERE year_removed = 2011 AND users.activity_status = 'n' ORDER BY dateremoved ASC, users.lastname";

$lapsed2013 = mysql_query($query_lapsed2013, $GCSMembership) or die(mysql_error());

$row_lapsed2013 = mysql_fetch_assoc($lapsed2013);

$totalRows_lapsed2013 = mysql_num_rows($lapsed2013);

mysql_select_db($database_GCSMembership, $GCSMembership);

$query_lapsed2013 = "SELECT users.user_id, users.lastname, users.middlename, users.firstname, users.dateremoved, users.year_removed FROM users WHERE users.year_removed = 2013 AND users.activity_status = 'n' ORDER BY users.dateremoved ASC,  users.lastname";

$lapsed2013 = mysql_query($query_lapsed2013, $GCSMembership) or die(mysql_error());

$row_lapsed2013 = mysql_fetch_assoc($lapsed2013);

$totalRows_lapsed2013 = mysql_num_rows($lapsed2013);

mysql_select_db($database_GCSMembership, $GCSMembership);

$query_listUsers = "SELECT users.user_id, users.lastname, users.firstname, users.email FROM users WHERE users.activity_status = 'y' ORDER BY users.lastname ASC";

$listUsers = mysql_query($query_listUsers, $GCSMembership) or die(mysql_error());

$row_listUsers = mysql_fetch_assoc($listUsers);

$totalRows_listUsers = mysql_num_rows($listUsers);

?>

Participating Frequently
September 6, 2013

>One thing I noticed here, is that the $query_lapsed2013

>set of commands is duplicated multiple times

That's a common problem and probably what's causing you trouble. You'll need to manually clean those up.