DB Error w/Debug

Creating an Event on a D6.1.6 site getting the following upon creating the event and hitting submit:

 

(
    [1] => Array
        (
            [file] => /home/digital9/public_html/inc/db.inc.php
            [line] => 114
            [function] => db_res
            [args] => Array
                (
                    [0] =>
                    [1] => 1
                )

        )

    [2] => Array
        (
            [file] => /home/digital9/public_html/inc/classes/BxDolEvents.php
            [line] => 923
            [function] => db_arr
            [args] => Array
                (
                    [0] =>
                )

        )

    [3] => Array
        (
            [file] => /home/digital9/public_html/events.php
            [line] => 126
            [function] => PageSDatingShowInfo
            [class] => BxDolEvents
            [object] => BxDolEvents Object
                (
                    [iEventsPerPage] => 10
                    [iIconSize] => 45
                    [iThumbSize] => 110
                    [iImgSize] => 340
                    [bAdminMode] =>
                    [sPicNotAvail] => images/icons/group_no_pic.gif
                    [sSpacerPath] => http://xxxxx.com/templates/base/images/icons/spacer.gif
                    [iLastInsertedID] => -1
                    [bUseFriendlyLinks] => 1
                )

            [type] => ->
            [args] => Array
                (
                )

        )

    [4] => Array
        (
            [file] => /home/digital9/public_html/events.php
            [line] => 79
            [function] => PageCompPageMainCode
            [args] => Array
                (
                )

        )

)
Called script: /events.php
Request parameters:

Array
(
    [event_main_category] => 7
    [event_category] => 99
    [event_title] => Testing Events
    [event_tags] => Test Events Erors
    [event_desc] => 

This is just a test of the Events System.  Will it go through with the Category & Sub-Category or will we achieve an error on this?

[event_country] => AU [event_city] => Somewhere [event_place] => Anywhere [event_start] => 2010-01-31 10:53:38 [gmk_lat] => 0 [gmk_lng] => 0 [gmk_zoom] => 2 [gmk_type] => 0 [action] => new [event_save] => Post Event [PHPSESSID] => 4d74d66a7863b0daa90ce1f289722e8c [strSec] => 8d629c50d8bec3c7d4f4df50c36fd459 [tmpCaptcha] => vtvf98 [memberID] => 69 [memberPassword] => 3a4b5f2f801ada677ac11ce2db032f1c [ZP_CAL] => \'fdow\':null,\'history\':\"2010/01/31/10/53,2034/07/28/00/00,2010/01/29/22/51\",\'sortOrder\':\"asc\",\'hsize\':9 [THE_CMT_TYPE] => Profile [phpbb3_widoo_u] => 140 [phpbb3_widoo_k] => [phpbb3_widoo_sid] => 0286ed9e660d748b4f85a9be748ffe42 [event_id] => 0

 

Not used to seeing one that just say the Query is empty.  What's up here?

 


Here is the string of code for inc/db.inc.php line 114:

 

 

function db_arr( $query, $error_checking = true ) {

  $query = timezone_setquery($query);
 
 $res = db_res( $query, $error_checking );
 if( !$res )
  return false;
 $arr = mysql_fetch_array( $res );
 return $arr;
}


Here is the line of code for inc/classes/BxDolEvents.php Line 923

 

  $aEventData = db_arr( $sQuery );
  if ( !is_array($aEventData) || count($aEventData) == 0 )
   return DesignBoxContent( '', '<center>'. _t('_Event is unavailable') .'</center>', $oTemplConfig -> PageSDatingShowInfo_db_num );

  $sQuery = "
   SELECT COUNT(*)
   FROM `SDatingParticipants`
   LEFT JOIN `Profiles` ON
    `SDatingParticipants`.`IDMember` = `Profiles`.`ID`
   WHERE
    `SDatingParticipants`.`IDEvent` = {$iEventID}
    AND `Profiles`.`Sex` = '{$sMemberSex}'
   ";


Ideas and help with this is appreciated.  My brain is just not seeing it.

Quote · 29 Jan 2010

Hello!

Possible trouble in this modified code:

$query = timezone_setquery($query);

Show us this function.

Regard

Quote · 30 Jan 2010

I checked line 114 and also anywhere for a $query = timezone_setquery($query); in the default db.inc.php and could not locate anything. Is this something you added? Im pretty sure you have modded this up a bit. Seem to have phpbb3 integrated as well.

Sorry for the delay.

Chris

Nothing to see here
Quote · 30 Jan 2010

 

I checked line 114 and also anywhere for a $query = timezone_setquery($query); in the default db.inc.php and could not locate anything. Is this something you added? Im pretty sure you have modded this up a bit. Seem to have phpbb3 integrated as well.

 

Sorry for the delay.

Chris

 

 Hi guys, thanks for the input.  The time_zone mod was done by someone else, checking to see if I can get a source-code file on it.  Here's the full db.inc.php file.  I've had a major cold all week and this still is not jumping out at me.  And yes, this has an iFramed phpBB3 integration on it too.

 

 

<?php

/***************************************************************************
*                            Dolphin Smart Community Builder
*                              -----------------
*     begin                : Mon Mar 23 2006
*     copyright            : (C) 2006 BoonEx Group
*     website              : http://www.boonex.com/
* This file is part of Dolphin - Smart Community Builder
*
* Dolphin is free software. This work is licensed under a Creative Commons Attribution 3.0 License.
* http://creativecommons.org/licenses/by/3.0/
*
* Dolphin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Creative Commons Attribution 3.0 License for more details.
* You should have received a copy of the Creative Commons Attribution 3.0 License along with Dolphin,
* see license.txt file; if not, write to marketing@boonex.com
***************************************************************************/

require_once("header.inc.php");
require_once( BX_DIRECTORY_PATH_INC . 'utils.inc.php' );

define( 'DB_FULL_VISUAL_PROCESSING', true );
define( 'DB_FULL_DEBUG_MODE', true );
define( 'DB_DO_EMAIL_ERROR_REPORT', true );

$MySQL = new CMySQL;

if( !$MySQL->connect() )
 genMySQLErr( 'Database connect failed' );

if( !$MySQL->select_db() )
 genMySQLErr( 'Database select failed' );

db_res( "SET NAMES 'utf8'" );

$cacheParam = array();

class CMySQL {
 var $host      = DATABASE_HOST;
 var $sock      = DATABASE_SOCK;
 var $port      = DATABASE_PORT;
 var $user      = DATABASE_USER;
 var $passwd    = DATABASE_PASS;
 var $db        = DATABASE_NAME;
 var $connected = false;
 var $link      = null;
 
 function connect() {
  if ( $this->connected )
   return;

  if( strlen($this->port) )
   $this->port = ":".$this->port;

  if ( strlen($this->sock) )
   $this->sock = ":".$this->sock;

  $this->link = @mysql_pconnect( $this->host . $this->port . $this->sock, $this->user, $this->passwd );
  mysql_query ("SET @@local.wait_timeout=9000;");
  mysql_query ("SET @@wait_timeout=9000;");
  mysql_query ("SET @@local.interactive_timeout=9000;");
  mysql_query ("SET @@interactive_timeout=9000;");
  mysql_query ("SET @@local.connect_timeout=9000;");
  mysql_query ("SET @@connect_timeout=9000;");
  
  if ( $this->link)
   $this->connected = true;

  return $this->connected;
 }

 function select_db() {
  return @mysql_select_db( $this->db );
 }
}

function db_list_tables( $error_checking = true ) {
 global $MySQL;

 $res = mysql_list_tables($MySQL->db);
 if ( $error_checking && !$res )
  genMySQLErr( 'Database list tables failed' );

 return $res;
}

function db_get_encoding ( $error_checking = true ) {
 global $MySQL;

 $res = mysql_client_encoding($MySQL->link);
 if ( $error_checking && !$res )
  genMySQLErr( 'Database get encoding error' );

 return $res;
}

function db_res( $query, $error_checking = true ) {
 global $MySQL;

  $query = timezone_setquery($query);
 $res = mysql_query( $query, $MySQL->link );
 if ( $error_checking && !$res )
  genMySQLErr( 'Database query error', $query );

 return $res;
}

function db_arr( $query, $error_checking = true ) {

  $query = timezone_setquery($query);
 
 $res = db_res( $query, $error_checking );
 if( !$res )
  return false;
 $arr = mysql_fetch_array( $res );
 return $arr;
}

function db_assoc_arr( $query, $error_checking = true ) {
   
  $query = timezone_setquery($query);
 
 $res = db_res( $query, $error_checking );
 if( !$res )
  return false;
 $arr = mysql_fetch_assoc( $res );
 return $arr;
}

function db_assoc_arr2( $query, $error_checking = true ) {
   
 
 $res = db_res( $query, $error_checking );
 if( !$res )
  return false;
 $arr = mysql_fetch_assoc( $res );
 return $arr;
}

function db_value( $query, $error_checking = true, $index = 0 ) {
 
  $query = timezone_setquery($query);
 
 $arr = db_arr( $query, $error_checking );
 $val = $arr[$index];
 return $val;
}

function fill_array( $res ) {
 global $MySQL;

 if (!$res)
  return false;

 $i = 0;
 $arr = array();
 while( $r = mysql_fetch_array( $res ) )
  $arr[$i++] = $r;

 return $arr;
}

function fill_assoc_array( $res ) {
 global $MySQL;

 if (!$res)
  return false;

 $i = 0;
 $arr = array();
 while( $r = mysql_fetch_assoc( $res ) )
  $arr[$i++] = $r;

 return $arr;
}

function getParam( $param_name, $use_cache = true ) {
 global $cacheParam;

 if ( $use_cache && isset($cacheParam[$param_name]) )
  return $cacheParam[$param_name];
 elseif ( !$line = db_assoc_arr2( "SELECT `VALUE` FROM `GlParams` WHERE `Name` = '$param_name'" ) )
  return false;
 $cacheParam[$param_name] = $line['VALUE'];
 return $line['VALUE'];
}

function getParamDesc( $param_name ) {
 if ( !$line = db_assoc_arr2( "SELECT `desc` FROM `GlParams` WHERE `Name` = '$param_name'" ) )
  return false;
 return $line['desc'];
}

function setParam( $param_name, $param_val ) {
 global $cacheParam;
 
 if ( !$res = db_res( "UPDATE `GlParams` SET `VALUE` = '".process_db_input($param_val)."' WHERE `Name` = '$param_name'" ) )
  return false;
 
 $cacheParam[$param_name] = $line[$param_val];
 return true;
}

function mysqlErrorReport() {
 global $site;
 mail( $site['bugReportMail'], "Error", "Error in $_SERVER[PHP_SELF]: " . mysql_error($GLOBALS['MySQL']->link) . "\nQuery: '$query'" );
}

function genMySQLErr( $out, $query ='' ) {
 global $site;
 
 $aBackTrace = debug_backtrace();
 unset( $aBackTrace[0] );
 
 if( $query ) {
  //try help to find error
  
  $aFoundError = array();
  
  foreach( $aBackTrace as $aCall ) {
   foreach( $aCall['args'] as $argNum => $argVal ) {
    if( is_string($argVal) and strcmp( $argVal, $query ) == 0 ) {
     $aFoundError['file']     = $aCall['file'];
     $aFoundError['line']     = $aCall['line'];
     $aFoundError['function'] = $aCall['function'];
     $aFoundError['arg']      = $argNum;
    }
   }
  }
  
  if( $aFoundError ) {
   $sFoundError = <<<EOJ
<b>Found error</b> in file <b>{$aFoundError['file']}</b><br />
at line <b>{$aFoundError['line']}</b>. Called <b>{$aFoundError['function']}</b> function
with erroneous argument #<b>{$aFoundError['arg']}</b><br />
<br />

EOJ;
  }
 }
 
 if( DB_FULL_VISUAL_PROCESSING ) {
  ?>
   <div style="border:2px solid red;padding:4px;width:600px;margin:0px auto;">
    <div style="text-align:center;background-color:red;color:white;font-weight:bold;">Error</div>
    <div style="text-align:center;"><?=$out?></div>
  <?
  if( DB_FULL_DEBUG_MODE ) {
   if( strlen( $query ) )
    echo "<div><b>Query:</b><br />{$query}</div>";
   
   echo '<div><b>Mysql error:</b><br />'.mysql_error($GLOBALS['MySQL']->link).'</div>';
   echo '<div style="overflow:scroll;height:300px;border:1px solid gray;">';
   echo $sFoundError;
   echo "<b>Debug backtrace:</b><br />";
   echoDbg( $aBackTrace );
   
   echo "<b>Called script:</b> {$_SERVER['PHP_SELF']}<br />";
   echo "<b>Request parameters:</b><br />";
   echoDbg( $_REQUEST );
   echo '</div>';
  }
  ?>
   </div>
  <?
 } else
  echo $out;
 
 if( DB_DO_EMAIL_ERROR_REPORT ) {
  $sMailBody = "Database error in <SiteName>\n";

  if( strlen( $query ) )
   $sMailBody .= "Query:\n{$query}\n\n";
  
  $sMailBody .= "Mysql error:\n" . mysql_error($GLOBALS['MySQL']->link) . "\n\n";
  
  $sMailBody .= strip_tags( $sFoundError );
  
  $sMailBody .= "Debug backtrace:\n" . print_r( $aBackTrace, true ) . "\n\n";
  $sMailBody .= "Called script: {$_SERVER['PHP_SELF']}\n\n";
  $sMailBody .= "Request parameters:\n" . print_r( $_REQUEST, true ) . "\n\n";
  
  $sMailBody .= "--\nAuto-report system\n";
  
  sendMail( $site['bugReportMail'], "Database error in <SiteName>", $sMailBody );
 }
 
 exit;
}

//TIMEZONE MOD

$sTimeZoneSet = getParam("TimeZoneSet");

function timezone_setquery($query)
{
global $sTimeZoneSet;

$aIP[]="198.22.92.11";
$aIP[]="222.127.224.219";
$aIP[]="85.166.143.90";

  if ( $sTimeZoneSet )
     {
 

     $query = str_replace("now()","'".date("Y-m-d H:i:s")."'",$query);
     $query = str_replace("Now()","'".date("Y-m-d H:i:s")."'",$query);
     $query = str_replace("NOW()","'".date("Y-m-d H:i:s")."'",$query);
                                                                                     
     $query = str_replace("UNIX_TIMESTAMP()","UNIX_TIMESTAMP('".date("Y-m-d H:i:s")."')",$query);
     $query = str_replace("unix_timestamp()","UNIX_TIMESTAMP('".date("Y-m-d H:i:s")."')",$query);
    
     if ( in_array($_SERVER[REMOTE_ADDR],$aIP) and 1 == 2)
     {
     echo "<br>".$sTimeZoneSet.$query;
     }
    
     }
return $query;
}
if ( $sTimeZoneSet )
   {
   date_default_timezone_set($sTimeZoneSet);
   }

?>

 


Line 114 string of code is highlighted for you.  This is just not jumping out at me here. 

Quote · 30 Jan 2010

I started my investigation here

[file] => /home/digital9/public_html/inc/classes/BxDolEvents.php
[line] => 923

Found the issue here -- it seems that this line causes the error line#881 :

$$sQuery =  "
SELECT

I guess it should be $sQuery not $$sQuery

Quote · 31 Jan 2010

 Oh Gawd do I feel stupid.  This is why friends don't let friends code on medication.  I must've looked at that thing a hundred times and never noticed the extr "$" on it.  Thanks Expertx

I started my investigation here

[file] => /home/digital9/public_html/inc/classes/BxDolEvents.php
[line] => 923

 

Found the issue here -- it seems that this line causes the error line#881 :

 

$$sQuery =  "
SELECT

I guess it should be $sQuery not $$sQuery

 

Quote · 31 Jan 2010
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.