Jump to content

Archived

This topic is now archived and is closed to further replies.

whatsupron

[SOLVED] mysql error

Recommended Posts

Hi i'm trying to select from mysql for my photo comments on my site and I get this error on my page

Error: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' 1' at line 1

SELECT added,from_user_id,comments FROM miphoto_photo_comments WHERE approved=1 AND photo_id='' ORDER BY added DESC LIMIT , 1

 

and here is the code that i'm trying to select from mysql also this is a custom mysql select.

$rResult = $oDb->select("added,from_user_id,comments","photo_comments","approved=1 AND photo_id='".$oDb->escape($iPhotoId)."'","ORDER BY added DESC LIMIT {$iStart}, {$iNumberOfComments}");

 

 

 

can anyone please help???

Share this post


Link to post
Share on other sites

Without knowing what inputs the method requires its hard to know what the actual end SQL query is.

Share this post


Link to post
Share on other sites

Well here is the full code for the function of sending comment for photos

function returnPhotoComments($iPhotoId, $iStart = 0, $iNumberOfComments = 1) {
global $oDb, $oTpl;

$oTpl->define(array('profile-ViewProfileMyPicturesPhotoCommentsEach'	=>	'rate/view_profile_my_pictures_photo_comments_each.tpl'));

if($iStart < 0) {
	$iStart = 0;
}
if($iNumberOfComments < 1) {
	$iNumberOfComments = 1;
}

$rResult = $oDb->select("added,from_user_id,comments","photo_comments","approved=1 AND photo_id='".$oDb->escape($iPhotoId)."'","ORDER BY added DESC LIMIT {$iStart}, {$iNumberOfComments}");
while($aData = $oDb->getRow($rResult)) {
	$oTpl->assign('RateViewProfileMyPicturesPhotoCommentsEachComment',$aData['comments']);
	$oTpl->assign('RateViewProfileMyPicturesPhotoCommentsEachDate',formatDateTime($aData['added']));

	setUserTemplateVariables($aData['from_user_id'],'RateViewProfileMyPicturesPhotoCommentsEach');

	$oTpl->parse('temp','.profile-ViewProfileMyPicturesPhotoCommentsEach');
}
$oDb->freeResult($rResult);

$sComments = $oTpl->getValue('temp');
$oTpl->clearVars('temp');

return $sComments;
}

Share this post


Link to post
Share on other sites

I'm talking about: $oDb->select() method.

well I looked to my index.php where it shows what those methods do and here it is

<?php

//=======================================
//###################################
//
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//###################################
//=======================================

define('IN_MIPHOTO',true);

require_once(dirname(__FILE__)."/include/functions.php");

$oLog->logEvent(__FILE__,__LINE__,"Include all files");

$sDo = initVar('do');

// Initialize Db class
$oDb = new cMySQLDB($gGlobals['database']['server'],$gGlobals['database']['port'],$gGlobals['database']['user'],$gGlobals['database']['password'],$gGlobals['database']['name'],$gGlobals['database']['prefix']);

// Initiate Plugin Classes
$cPlugins = new cMicroScriptsPluginServer;
$cDummyPluginClient = new cMicroScriptsPluginClient;

$oLog->logEvent(__FILE__,__LINE__,"Create database, plugin objects");

$oDb->connect();
$oDb->selectdb();

$oCache = new cMicroCache();
$oCache->loadCache(CACHE_CONFIG_TABLE,false);
$oCache->loadCache(CACHE_COUNTRIES_TABLE,false);
$oCache->loadCache(CACHE_PROFILE_TABLE,false);
$oCache->loadCache(CACHE_CATEGORIES_TABLE,false);
$oCache->loadCache(CACHE_PLUGINS_TABLE,false);
$oCache->loadCache(CACHE_LANGUAGES_TABLE,false);

// Lets do a database version check to make sure this version of the script is the same as what is in the database...
$sDatabaseVersion = strtolower(trim(getConfig('version',0)));
if($sDatabaseVersion != MIPHOTO_VERSION) {
$sError = "This version (".MIPHOTO_VERSION.") is not compatible with the version in the database ({$sDatabaseVersion}).";

if(!@ini_get('display_errors')) {
	echo $sError;
}
trigger_error($sError, E_USER_ERROR);
}

if(MIPHOTO_FEATURE_PHOTO_DETAILS) {
$oCache->loadCache(CACHE_PHOTO_FIELDS_TABLE,false);
}

$oLog->logEvent(__FILE__,__LINE__,"Loaded cache files");

if(!checkLicense()) {
$oDb->disconnect();
$oDb = NULL;
exit;
}

$oLog->logEvent(__FILE__,__LINE__,"License Check");

$bLoad = true;

if((int)getConfig('topnew_update_timestamp',0) <= time()) {
$__IN_CLIENT = 1;

require_once(dirname(__FILE__)."/".ADMIN_DIR."/admin.functions.php");
// Rebuild the top users/photos/videos cache
rebuildTopUsersCache(false,false,false);

// Rebuild the new users/photos/videos cache
rebuildTopUsersCache(true);

$bLoad = false;
}

if($bLoad) {
$oCache->loadCache(CACHE_TOP_USERS,false);

if(MIPHOTO_FEATURES_SIDE_NEW_MEMBERS) {
	$oCache->loadCache(CACHE_NEW_USERS,false);
}
}

$oLog->logEvent(__FILE__,__LINE__,"Load TOP/NEW cache");

if(MIPHOTO_FEATURE_IMAGE2FTP)
$oCache->loadCache(CACHE_IMAGE2FTP_TABLE,false);

$gGlobals['datetime']['servertimezone'] = intval(getConfig('servertimezone',0));
$gGlobals['maxresultsperpage'] = intval(getConfig('maxresultsperpage',0));
$gGlobals['topnumber'] = intval(getConfig('topnumber',0));
$gGlobals['rating']['graphic'] = intval(getConfig('graphicrating',0));
$gGlobals['images']['imagefilepath'] = getConfig('photofilepath',0);
$gGlobals['sidetop'] = intval(getConfig('sidetop',0));
$gGlobals['rating']['type'] = intval(getConfig('rateusersorphotos',0));
//$gGlobals['allowhtmlcode'] = intval(getConfig('allowmembershtmlinfields',0));
$gGlobals['allowhtmlcode'] = FEATURE_FCKEDITOR ? 1 : intval(getConfig('allowmembershtmlinfields',0));

$gGlobals['agelimits']['maxage'] = intval(getConfig('maxage',0));
$gGlobals['agelimits']['minage'] = intval(getConfig('minage',0));
$gGlobals['wraptext']['profile'] = intval(getConfig('wraptext_profile',0));
$gGlobals['wraptext']['other'] = intval(getConfig('wraptext_other',0));

if($gGlobals['use_sessions']) {
// Set the cookie lifetime to 30 days for sessions
// For just cookies this is done in content/login.php
if(initVar('remember_login',HTTP_POST,true,0)) {
	//@ini_set('session.use_cookies','1');
	//@ini_set('session.use_only_cookies','1');
	//@ini_set('session.use_trans_sid','0');
	session_set_cookie_params(1296000);
}

session_name($gGlobals['cookieprefix']);

if(!session_id())
	session_start();

if(isset($_SESSION['sessionlast'])) {
	$gGlobals['user']['session_last'] = $_SESSION['sessionlast'];
}
} else {
if(isset($_COOKIE[$gGlobals['cookieprefix'].'sessionlast'])) {
	$gGlobals['user']['session_last'] = $_COOKIE[$gGlobals['cookieprefix'].'sessionlast'];
}
}

$gGlobals['user']['loggedin'] = ( ($sDo=='logout') ? 0 : verifyCookie() );
if($gGlobals['user']['loggedin']) {
$gGlobals['user']['id'] = getUserId();
    $gGlobals['user']['name'] = getUserName();
    $aData = $oDb->getRow($oDb->select("email,timezone,language_id","users","id='".$oDb->escape($gGlobals['user']['id'])."'"));
$gGlobals['user']['timezone'] = $aData['timezone'];
$gGlobals['user']['premier'] = isUserPremier();
$gGlobals['user']['language']['id'] = $aData['language_id'];

// Only will work with new definition table
//$oDb->query("INSERT INTO {$gGlobals['database']['prefix']}_users_ip_addresses (added,user_id,ip_address) VALUES (NOW(),'".$oDb->escape($gGlobals['user']['id'])."','".$oDb->escape($gGlobals['user']['ipaddress'])."') ON DUPLICATE KEY UPDATE updated=NOW()");
if($oDb->getResult($oDb->select("COUNT(*)","users_ip_addresses","user_id='".$oDb->escape($gGlobals['user']['id'])."' AND ip_address='".$oDb->escape($gGlobals['user']['ipaddress'])."'")) < 1) {
	$oDb->query("INSERT INTO {$gGlobals['database']['prefix']}_users_ip_addresses (added,user_id,ip_address) VALUES (NOW(),'".$oDb->escape($gGlobals['user']['id'])."','".$oDb->escape($gGlobals['user']['ipaddress'])."')");
} else {
	// Do a query to update the updated timestamp?
	// Or maybe start counting the number of times the site is accessed by a certain IP address
}

if($oDb->getResult($oDb->select("COUNT(*)","bans","ip_address='".$oDb->escape($gGlobals['user']['ipaddress'])."'".(!empty($aData['email']) ? " OR email LIKE '".$oDb->escape($aData['email'])."'" : "").(!empty($gGlobals['user']['name']) ? " OR username LIKE '".$oDb->escape($gGlobals['user']['name'])."'" : ""),"LIMIT 1")) > 0) {
	$oDb->disconnect();
	Header("HTTP/1.1 404 Not Found");
	exit;
}
} else {
if($oDb->getResult($oDb->select("COUNT(*)","bans","ip_address='".$oDb->escape($gGlobals['user']['ipaddress'])."'","LIMIT 1")) > 0) {
	$oDb->disconnect();
	Header("HTTP/1.1 404 Not Found");
	exit;
}
}

// See if the user has attempted to change language via the change language form
$iLanguage = initVar('language',HTTP_POST,true,0);

// or by the URL
if(initVar('changelanguage',HTTP_GET,true,0) == '1' && empty($iLanguage))
$iLanguage = initVar('language',HTTP_GET,true,0);

if(empty($gGlobals['user']['language']['id']) || !empty($iLanguage)) {
if($gGlobals['use_sessions'])
	$gGlobals['user']['language']['id'] = base64_decode($_SESSION['language']);
else {
	if(isset($_COOKIE[$gGlobals['cookieprefix'].'language'])) {
		$gGlobals['user']['language']['id'] = base64_decode($_COOKIE[$gGlobals['cookieprefix'].'language']);
	}
}

if(!empty($iLanguage)) {
	if($gGlobals['use_sessions'])
		$_SESSION['language'] = base64_encode($iLanguage);
	else
		setcookie($gGlobals['cookieprefix']."language",base64_encode($iLanguage),time()+1296000,'/');
		//setcookie($gGlobals['cookieprefix']."language",base64_encode($iLanguage),time()+1296000,'/','.'.getConfig('siteaddress',0));

	$gGlobals['user']['language']['id'] = $iLanguage;
}

if($gGlobals['user']['loggedin'])
	$oDb->update("users",array('language_id'	=>	$gGlobals['user']['language']['id']),"id='".$oDb->escape(getUserId())."'");
}

// We still don't have a language ID, so attempt to detect the language based off the user's browser information
if(empty($gGlobals['user']['language']['id'])) {
$aAcceptLanguage = explode(";",$HTTP_SERVER_VARS['HTTP_ACCEPT_LANGUAGE']);
$aCharacterCodes = explode(",",$aAcceptLanguage[0]);

$sWhere = "enabled=1";

if(sizeof($aCharacterCodes)) {
	// Remember to clean up the input before putting it in SQL query!!!
	$aCharacterCodes = array_map("mysql_escape_string",$aCharacterCodes);
	$sWhere .= " AND character_code IN ('".implode("','",$aCharacterCodes)."')";
}

$gGlobals['user']['language']['id'] = $oDb->getResult($oDb->select("id","languages",$sWhere,"LIMIT 1"));
}

$gGlobals['html_directory'] = getHTMLDirectoryWithLanguage();

$gGlobals['datetime']['format'] = getConfig('dateformat');
$gGlobals['datetime']['dateformat'] = getConfig('dateonlyformat');

$gGlobals['onlinestatustext'] = getConfig('useronlinestatustext');
$gGlobals['offlinestatustext'] = getConfig('userofflinestatustext');
$gGlobals['rating']['nonetext'] = getConfig('nonetext');
$gGlobals['rating']['imagepath'] = "html_{$gGlobals['user']['language']['id']}/images/rank";


$oTpl = new cMiTemplate($gGlobals['html_directory']);
$oTpl->assign('HTMLDirectory',$gGlobals['html_directory'],false);
$oTpl->assign('UserName',getUserName());
$oTpl->assign('UserLoggedIn',$gGlobals['user']['loggedin']);
$oTpl->define($aTemplateFileList);

$oCustoms->runCustoms(FILE_INDEX,4);

if($gGlobals['user']['loggedin'] == -2) {
$oTpl->assign('Content',getConfig('errorprofilenotapproved'),false);
}
elseif($gGlobals['user']['loggedin'] == -1) {
$oTpl->assign('Content',getConfig('erroraccountsuspended'),false);
}

if(!getConfig('siteactive',0)) {
echo getFile("maintenance");
$oDb->disconnect();
$oDb = NULL;
exit;
}

$oDb->query("UPDATE {$gGlobals['database']['prefix']}_config SET thevalue=(thevalue+1) WHERE thekey='counter'");

// Load only the Plugins that the admin wants loaded
$aPlugins = $oCache->aCache[CACHE_PLUGINS_TABLE];
if(!is_array($aPlugins))
$aPlugins = array();
foreach($aPlugins as $iId => $sFileName) {
$cPlugins->loadPlugin($sFileName);
}

$gGlobals['user']['premier'] = isUserPremier();

for($i=1;$i<=3;$i++) {
$oTpl->assign('Advertisement'.$i,'',false);
}

// Call a function for the plugins to do needed operations before we get started
$cPlugins->callPluginFunction(PLUGIN_FUNCTION_MAIN_START);

// Code for managing active_user table
$oDb->delete("activeusers","((UNIX_TIMESTAMP() - UNIX_TIMESTAMP(laston)) >= '".$oDb->escape(ACTIVE_MEMBERS_INACTIVE_DELAY)."') OR ip='".$oDb->escape($gGlobals['user']['ipaddress'])."'".(($gGlobals['user']['loggedin'])?" OR user='".$oDb->escape($gGlobals['user']['id'])."'":""));
$oDb->query("INSERT INTO {$gGlobals['database']['prefix']}_activeusers (user,ip,laston) VALUES ('".$oDb->escape($gGlobals['user']['id'])."','".$oDb->escape($gGlobals['user']['ipaddress'])."',NOW())");
// End of code for active users

$rResult = $oDb->select("user","activeusers","user!=0");
while($aData = $oDb->getRow($rResult)) {
$oCache->addValue(CACHE_ACTIVE_USERS_DATA,$aData['user'],$aData['user']);
}
$oDb->freeResult($rResult);

$iUnreadPrivateMessages = 0;

if($gGlobals['user']['loggedin']) {
$iUnreadPrivateMessages = $oDb->getResult($oDb->select("COUNT(*)","pms USE INDEX (pms_new_msgs)","toid='".$oDb->escape($gGlobals['user']['id'])."' AND seen='0' AND todeleted='0'"));
$oTpl->assign('ControlPanelMemberNavbarNewMessages',$iUnreadPrivateMessages,false);
}

$oTpl->assign("PMPopUp","");

if(empty($sDo) && $iUnreadPrivateMessages > 0) {
$sResult = $oDb->getResult($oDb->select("popuppm","users","id='".$oDb->escape($gGlobals['user']['id'])."'","LIMIT 1"));
if($sResult == "1") {
    $oTpl->assign("PMPopUp","popUpPMSWin({$iUnreadPrivateMessages});");
}
}



$sSiteAddress = getConfig('siteaddress',0);
$oTpl->assign('SiteDomain',$sSiteAddress,false);
$oTpl->assign('SiteAddress',$sSiteAddress,false);

// Fill in stats vars
$iActiveMembers = intval(@sizeof($oCache->aCache[CACHE_ACTIVE_USERS_DATA]));
$iActiveVisitors = intval($oDb->getResult($oDb->select("COUNT(*)","activeusers","user='0'")));
$oTpl->assign('TotalActiveUsers',$iActiveMembers + $iActiveVisitors,false);
$oTpl->assign('MembersOnline',$iActiveMembers,false);
$oTpl->assign('VisitorsOnline',$iActiveVisitors,false);
$oTpl->assign('RegisteredMembers',getConfig('countmembers',0),false);
$oTpl->assign('RatableMembers',getConfig('countmembersratable',0),false);
$oTpl->assign('SubmittedPictures',getConfig('countphotos',0),false);
$oTpl->assign('SubmittedVideos',getConfig('countvideos',0),false);
$oTpl->assign('SitePageViews',getConfig('counter',0),false);

$oTpl->assign('PhotoAlbums',getConfig('countphotoalbums',0),false);
$oTpl->assign('PrivatePhotoAlbums',getConfig('countprivatephotoalbums',0),false);
$oTpl->assign('TotalVotes',getConfig('counttotalvotes',0),false);
$oTpl->assign('AverageRating',getConfig('countaveragerating',0),false);
$oTpl->assign('AverageVotesPerUser',getConfig('countaveragevotes',0),false);
$oTpl->assign('NewMembersToday',getConfig('countnewmemberstoday',0),false);
$oTpl->assign('NewMembersYesterday',getConfig('countnewmembersyesterday',0),false);
$oTpl->assign('NewMembersPastWeek',getConfig('countnewmemberspastweek',0),false);
$oTpl->assign('NewMembersPastMonth',getConfig('countnewmemberspastmonth',0),false);
$oTpl->assign('NewMembersPastYear',getConfig('countnewmemberspastyear',0),false);


// Put out client IP Address
$oTpl->assign('IPAddress',$gGlobals['user']['ipaddress'],false);
$oTpl->assign('SiteTitle',getconfig('sitename'),false);

// Metatag Stuff
$oTpl->assign('MetatagTitle',getconfig('metatagstitle'),false);
$oTpl->assign('MetatagName',getconfig('metatagsname'),false);
$oTpl->assign('MetatagKeywords',getconfig('metatagskeywords'),false);
$oTpl->assign('MetatagPictureKeywords',getconfig('metatagspicturekeywords'),false);
$oTpl->assign('MetatagDescription',getconfig('metatagsdescription'),false);

// Shit for return URL after login
$gGlobals['returnurl'] = urlencode(initVar('returnurl'));
if(empty($gGlobals['returnurl'])) {
$gGlobals['returnurl'] = $HTTP_SERVER_VARS['PHP_SELF']."?";
foreach($HTTP_GET_VARS as $getVar => $sGetVar) {
	$sGetVar = stripslashes($sGetVar);
	$gGlobals['returnurl'] .= "&{$getVar}={$sGetVar}";
}
$gGlobals['returnurl'] = urlencode($gGlobals['returnurl']);
}
$oTpl->assign('ReturnURL',$gGlobals['returnurl'],false);
$oTpl->assign('ReturnURLNoEncode',urldecode($gGlobals['returnurl']),false);

$sLanguageOptions = "";

$aLanguages = $oCache->aCache[CACHE_LANGUAGES_TABLE];
foreach($aLanguages as $iLanguageId => $sLanguageName) {
$sLanguageOptions .= "<option value='{$iLanguageId}'".(($iLanguageId == $gGlobals['user']['language']['id'])?" selected":"").">{$sLanguageName}</option>";
}
$oTpl->assign('LanguageOptions',$sLanguageOptions,false);

$oTpl->assign('CategoriesOptions',getCategoryListSelectBox(initVar('gender')),false);
$oTpl->assign('DateYearOptions',getDateYearSelectBoxOptions(),false);
$oTpl->assign('AgeOptions',getAgeSelectBoxOptions(),false);
$oTpl->assign('ErrorMessage','',false);
$oTpl->assign('ErrorMessageTable','',false);




// Fill in the top number ranking
if($oCustoms->runCustoms(FILE_INDEX,2)) {
} else {
$aCategories = $oCache->aCache[CACHE_CATEGORIES_TABLE];
foreach($aCategories as $iId => $aCat) {
	setTopNewTemplateVariables($iId);
}
}

$oTpl->assign('SideLogin','',false);
$outContent = "";
if(!$gGlobals['user']['loggedin'] && $sDo != "login") {
$gGlobals['showlogin'] = 1;
$oTpl->parse('SideLogin','login-SideLogin');
}

// Code for previous photo
$oTpl->assign('PreviousPhoto','',false);
$iPreviousPhoto = initVar('prevphoto');

if($iPreviousPhoto > 0) {
if($gGlobals['rating']['type'] == RATE_USERS_ONLY) {
	$rResult = $oDb->select("rating,votes","users","id='".$oDb->escape($iPreviousPhoto)."'");
}
elseif($gGlobals['rating']['type'] == RATE_VIDEOS_ONLY) {
	$rResult = $oDb->select("rating,votes","videos","id='".$oDb->escape($iPreviousPhoto)."'");
}
elseif($gGlobals['rating']['type'] == RATE_PHOTOS_ONLY) {
	$rResult = $oDb->select("rating,votes","photos","id='".$oDb->escape($iPreviousPhoto)."'");
}
elseif($gGlobals['rating']['type'] == RATE_PHOTOS_VIDEOS) {
	if(initVar('v') == '1') {
		$rResult = $oDb->select("rating,votes","videos","id='".$oDb->escape($iPreviousPhoto)."'");
	} else {
		$rResult = $oDb->select("rating,votes","photos","id='".$oDb->escape($iPreviousPhoto)."'");
	}
}

if($oDb->getRowCount($rResult) > 0) {
	$iRating = initVar('rating');
	$aData = $oDb->getRow($rResult);

	if($gGlobals['rating']['type'] == RATE_USERS_ONLY) {
		$oTpl->assign('PreviousPhotoUserPhoto',getImageThumbnailLink(-1,false,THUMBNAIL_SIZE_PREVIOUSPHOTO,false,false,false,true,"",$iPreviousPhoto));
	}
	elseif($gGlobals['rating']['type'] == RATE_PHOTOS_ONLY || ($gGlobals['rating']['type'] == RATE_PHOTOS_VIDEOS && initVar('v') != '1')) {
		$oTpl->assign('PreviousPhotoUserPhoto',getImageThumbnailLink($iPreviousPhoto,false,THUMBNAIL_SIZE_PREVIOUSPHOTO));
	}
	elseif($gGlobals['rating']['type'] == RATE_VIDEOS_ONLY || ($gGlobals['rating']['type'] == RATE_PHOTOS_VIDEOS && initVar('v') == '1')) {
		$oTpl->assign('PreviousPhotoUserPhoto',getImageThumbnailLink($iPreviousPhoto,false,THUMBNAIL_SIZE_PREVIOUSPHOTO,false,false,true));
	}


	$oTpl->assign('PreviousPhotoUserAverageRating',formatRating($aData['rating'],$aData['votes'],0));
	$oTpl->assign('PreviousPhotoUserYouRated',formatRating($iRating,1,0,false,false,false,false));
	$oTpl->parse('PreviousPhoto','rate-PreviousPhoto');
}
$oDb->freeResult($rResult);
}
// End of code for previous photo


$oCustoms->runCustoms(FILE_INDEX,1);


$oTpl->assign('MemberNavBar','',false);
$oTpl->assign('UserId','',false);

if($gGlobals['user']['loggedin']) {
$oTpl->assign('UserId',$gGlobals['user']['id'],false);
$oTpl->assign('ControlPanelMemberNavbarUserId',$gGlobals['user']['id']);
$oTpl->assign('ControlPanelMemberNavbarNewMessages',$iUnreadPrivateMessages,false);
$oTpl->assign('ControlPanelMemberNavbarNewMiBuddyRequests',$oDb->getResult($oDb->select("COUNT(*)","mibuddies","approved='0' AND buddy_id='".$oDb->escape(getUserId())."'")),false);
$oTpl->parse('MemberNavBar','controlPanel-NavBar');

$sMsg = replaceVars(getConfig('welcomemessage'),'UserName',$gGlobals['user']['name']);
$sMsg = replaceVars($sMsg,'UnreadPrivateMessages',$iUnreadPrivateMessages);
$oTpl->assign('WelcomeMessage',$sMsg,false);
} else {
$oTpl->assign('WelcomeMessage',getConfig('welcomemessagenotloggedin'),false);
}

// Check to see if the user has a payment due, if so, only show them the subscriptions page when the are logged in
if($gGlobals['product']['pro'] && getConfig('paymentpostprofile',0) && strtolower($sDo) != 'logout') {
$aData = $oDb->getRow($oDb->select("special_flags","users","id=".getUserId()));
if($aData['special_flags'] & USERS_SPECIAL_FLAGS_PAYMENT_DUE) {
	$sDo = $HTTP_GET_VARS['do'] = "subscriptions";
}
}

$oLog->logEvent(__FILE__,__LINE__,"Set global template variables");

$oTpl->assign('Content','',false);

switch(strtolower($sDo)) {
case "rate": {
	$sAct = initVar('act');
	switch($sAct) {
		case 'profile':
			include(dirname(__FILE__)."/content/profile.php");
			break;
		case 'top':
		case 'new':
			include(dirname(__FILE__)."/content/top_new.php");
			break;
		default:
			include(dirname(__FILE__)."/content/rate.php");
	}
	break;
}
    case "login":
    case "register":
    case "search":
    case "report":
    case "contact":
    case "joinemail":
    case "pm":
    case "mystats":
    case "mypictures":
    case "myprofile":
    case "mycomments":
    case "email":
   	case "mibuddies":
   	case "deleteaccount":
   	case "myblocklist":
   	case "myvideos":
case "activemembers":
    	include(dirname(__FILE__)."/content/{$sDo}.php");
    	break;
case "mygalleries":
	include(dirname(__FILE__)."/content/mypictures.gallery_requests.php");
	break;
    case "referral":
    	include(dirname(__FILE__)."/content/referral.php");
    	break;
    case "auth":
    case "authaccount":
    	include(dirname(__FILE__)."/content/auth.php");
    	break;
    case "logout":
    	if($gGlobals['use_sessions']) {
	    $_SESSION = array();
		//setcookie(session_name(),'',time()-5184000,'/','.'.getConfig('siteaddress',0));
		setcookie(session_name(),'',time()-5184000,'/');
	    session_destroy();
    	} else {
    		//setcookie($gGlobals['cookieprefix'].'user',"",time()+1,'/','.'.getConfig('siteaddress',0));
    		//setcookie($gGlobals['cookieprefix'].'user',"",time()-5184000,'/','.'.getConfig('siteaddress',0));
    		setcookie($gGlobals['cookieprefix'].'user',"",time()-5184000,'/');
        //setcookie($gGlobals['cookieprefix'].'pass',"",time()-5184000,'/','.'.getConfig('siteaddress',0));
        setcookie($gGlobals['cookieprefix'].'pass',"",time()-5184000,'/');
        //setcookie($gGlobals['cookieprefix'].'sessionstart',"",time()+1,'/','.'.getConfig('siteaddress',0));
        //setcookie($gGlobals['cookieprefix'].'sessionstart',"",time()-5184000,'/','.'.getConfig('siteaddress',0));
        setcookie($gGlobals['cookieprefix'].'sessionstart',"",time()-5184000,'/');
    	}
    	include(dirname(__FILE__)."/content/main.php");
    	break;
    default:
    	$bShowDefault = true;

	if($oCustoms->runCustoms(FILE_INDEX,3)) {
	} else {
    	if(!empty($sDo) && $bShowDefault) {
    		$aData = $oDb->getRow($oDb->select("id,require_login","additional_pages","page_name='".$oDb->escape($sDo)."'"));

    		if((int)$aData['id'] > 0) {
    			if($aData['require_login'] && !$gGlobals['user']['loggedin']) {
    				include(dirname(__FILE__)."/content/login.php");
    				$bShowDefault = false;
    			} else {
    				//$oTpl->assign('Content',getFile($sDo),false);
    				$oTpl->define(array('additional_page'	=>	$sDo.'.tpl'));
    				$oTpl->parse('Content','additional_page',false);
    				$bShowDefault = false;
    			}
    		}
    	}

    	if($bShowDefault) {
    		if(!($cPlugins->callPluginFunction(PLUGIN_FUNCTION_CLIENT_OUTPUT))) {
    			include(dirname(__FILE__)."/content/main.php");
    		}
    	}
	}
}

$oLog->logEvent(__FILE__,__LINE__,"Content Code Execution");

// Call operation in plugins to do things since we are done
$cPlugins->callPluginFunction(PLUGIN_FUNCTION_MAIN_END);

if(MIPHOTO_DEV) {
$oTpl->assign('SQLNumberOfQueries',$oDb->iNumQueries);
$oTpl->assign('SQLNumberOfSelectQueries',$oDb->iSelectQueries);
$oTpl->assign('SQLNumberOfOtherQueries',$oDb->iNumQueries - $oDb->iSelectQueries);

echo "<!--\n";
print_r($oDb->aQueriesPerTable);
echo "\n\n\nNOW THE QUERIES\n\n\n";
print_r($oDb->aQueries);
echo "\n-->";
}

// See if there was an error!
if($oTpl->getValue('ErrorMessage') != "") {
// There was an error somewhere... lets display the error message to the user...
$oTpl->parse('ErrorMessageTable','errorTable');
}

$oTpl->display("index");


$oLog->logEvent(__FILE__,__LINE__,"Template Index File display");

$oDb->disconnect();

// Set to null so PHP knows to delete, some PHP systems where not clearing the memory unless this was here
$oDb = NULL;
$oTpl = NULL;

$oLog->logEvent(__FILE__,__LINE__,"Execution End");
$oLog->closeLog();

?>

Share this post


Link to post
Share on other sites

No. The methods in question are defined within the cMySQLDB class.

 

And please, post only what is relevent.

Share this post


Link to post
Share on other sites

and here is mysql.class.inc file just to show the mysql functions

<?php

if(!defined("IN_MIPHOTO")) {
trigger_error("Unable to process {$HTTP_SERVER_VARS['PHP_SELF']}", E_USER_ERROR);
}

if(!defined('MIPHOTO_INSTALL'))
define('MIPHOTO_INSTALL',0,true);

$sAct2 = isset($HTTP_GET_VARS['act']) ? stripslashes($HTTP_GET_VARS['act']) : "";

if($sAct2 == "goinstall" || MIPHOTO_INSTALL)
@include_once(dirname(__FILE__)."/config.php");
else
require_once(dirname(__FILE__)."/config.php");



if(!defined('MYSQL_PCONNNECT'))
define('MYSQL_PCONNNECT',0,true);

if(!defined('MYSQL_CHARACTER_SET'))
define('MYSQL_CHARACTER_SET','utf8');

define('MYSQL_NO_QUOTES_ESCAPE_CHARACTERS','&~^@()A');
define('MYSQL_USE_MYSQLI',function_exists('mysqli_connect'));


require_once(dirname(__FILE__)."/globals.php");

/*
Returns an Array

Array ('thekey' => '','thevalue' => '','language_id' => '')
*/

function returnConfigTableFields($sKey, $sValue = "", $iLanguageId = 0) {
return array('thekey' => $sKey, 'thevalue' => $sValue, 'language_id' => $iLanguageId);
}


class cMySQLDB {
var $conn;
var $oDb;
var $sDatabaseName;

var $sCurrentDB;

var $sServer;
var $sPort;
var $sUsername;
var $sPassword;
var $sTablePrefix;
var $iNumQueries;
var $iSelectQueries;
var $aQueries;
var $db_version;

var $aQueriesPerTable;

function cMySQLDB($sServer,$sPort,$sUsername,$sPassword,$sDatabaseName,$sTablePrefix) {
	$this->sDatabaseName = $sDatabaseName;
	$this->sServer = $sServer;
	$this->sPort = $sPort;
	$this->sUsername = $sUsername;
	$this->sPassword = $sPassword;
	$this->sTablePrefix = $sTablePrefix;
	$this->iNumQueries = $this->iSelectQueries = 0;
}

function connect($bHideError = false, $bInstall = false, $bNewLink = false, $bDie = true) {
        if(MYSQL_USE_MYSQLI) {
        	if($bInstall) {
            	$this->conn = @mysqli_connect($this->sServer,$this->sUsername,$this->sPassword,"",$this->sPort) or reportError($this,"",$bHideError,true,$bDie);
        	} else {
	        $this->conn = @mysqli_connect($this->sServer,$this->sUsername,$this->sPassword,$this->sDatabaseName,$this->sPort) or reportError($this,"",$bHideError,true,$bDie);
	        $this->sCurrentDB = $sDatabaseName;
        	}
        } else {
        	if(MYSQL_PCONNNECT) {
        		$this->conn = @mysql_pconnect($this->sServer.":".$this->sPort,$this->sUsername,$this->sPassword) or reportError($this,"",$bHideError,true,$bDie);
        	} else {
			$this->conn = @mysql_connect($this->sServer.":".$this->sPort,$this->sUsername,$this->sPassword,$bNewLink) or reportError($this,"",$bHideError,true,$bDie);
        	}
        }


	$aMySQLVersion = $this->version();

	if($aMySQLVersion[0] >= 5) {
		// to prevent MySQL 5 strict errors with inputed data and create tables
		$this->query("SET SQL_MODE = 'MYSQL40'",false,true);
	}
	if((($aMySQLVersion[0] == 4 && $aMySQLVersion[1] >= 1) || ($aMySQLVersion[0] >= 5)) && !CUSTOM_ROBERT_281) {
		if(defined('MYSQL_CHARACTER_SET')) {
			if(MYSQL_CHARACTER_SET != '') {
				$this->query("SET NAMES '".MYSQL_CHARACTER_SET."'",false,true);
			//$this->query("SET SQL_MODE='NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'",false,true);
			//$this->query("SET @@character_set_server=".MYSQL_CHARACTER_SET,false,true);
			}
		}
	}

	$this->iNumQueries = $this->iSelectQueries = 0;

        return $this->conn;
}

function disconnect() {
        if(MYSQL_USE_MYSQLI)
        @mysqli_close($this->conn);
        else
		@mysql_close($this->conn);

	$this->conn = NULL;
}

/*
// NOT IMPLEMENTED BECAUSE YOU GO THE OPERATORS - AND,OR,XOR,>=,<,etc
function delete($sTable,$aWhere) {
	global $gGlobals;

	if(empty($sTable) || gettype($aWhere) != "array" || sizeof($aWhere) < 1)
		return 0;

	$sWhere = "";

	foreach($aWhere as $sField => $sFieldValue)
		$sWhere .= "{$sField}=".((substr($sFieldValue,0,strlen(MYSQL_NO_QUOTES_ESCAPE_CHARACTERS)) == MYSQL_NO_QUOTES_ESCAPE_CHARACTERS)?"(".substr($sFieldValue,strlen(MYSQL_NO_QUOTES_ESCAPE_CHARACTERS)).")":"'".$this->escape($sFieldValue)."'").", ";

	$sWhere = @substr($sWhere,0,-2);

	return $this->query("DELETE FROM {$this->sTablePrefix}_{$sTable}".((!empty($sWhere))?" WHERE {$sWhere}":""));
}
*/
function delete($sTable,$sWhere,$sOther = "") {
	global $gGlobals;

	if(empty($sTable))
		return 0;

	return $this->query("DELETE FROM {$this->sTablePrefix}_{$sTable}".((!empty($sWhere))?" WHERE {$sWhere}":"")." {$sOther}");
}


function insert($sTable, $aFields, $sOther = "", $bQuiet = false) {
	global $gGlobals;
	if(empty($sTable) || gettype($aFields) != "array" || sizeof($aFields) < 1)
		return 0;

	$sFields = $sFieldsValues = "";

	foreach($aFields as $sField => $sFieldValue) {
		$sFields .= "{$sField}, ";
		$sFieldsValues .= ((substr($sFieldValue,0,strlen(MYSQL_NO_QUOTES_ESCAPE_CHARACTERS)) == MYSQL_NO_QUOTES_ESCAPE_CHARACTERS)?"(".substr($sFieldValue,strlen(MYSQL_NO_QUOTES_ESCAPE_CHARACTERS)).")":"'".$this->escape($sFieldValue)."'").", ";
	}

	$sFields = substr($sFields,0,-2);
	$sFieldsValues = substr($sFieldsValues,0,-2);

	return $this->query("INSERT INTO {$this->sTablePrefix}_{$sTable} ({$sFields}) VALUES ({$sFieldsValues}) {$sOther}",!$bQuiet,$bQuiet);
}

function update($sTable,$aFields,$sWhere = "", $sOptions = "") {
	global $gGlobals;
	if(empty($sTable) || gettype($aFields) != "array" || sizeof($aFields) < 1)
		return 0;

	$sFields = "";

	foreach($aFields as $sField => $sFieldValue)
		$sFields .= "`{$sField}`=".((substr($sFieldValue,0,strlen(MYSQL_NO_QUOTES_ESCAPE_CHARACTERS)) == MYSQL_NO_QUOTES_ESCAPE_CHARACTERS) ? "(".substr($sFieldValue,strlen(MYSQL_NO_QUOTES_ESCAPE_CHARACTERS)).")" : "'".$this->escape($sFieldValue)."'").", ";

	$sFields = substr($sFields,0,-2);

	return $this->query("UPDATE `{$this->sTablePrefix}_{$sTable}` SET {$sFields}".((!empty($sWhere))?" WHERE {$sWhere}":"")." {$sOptions}");
}

    function escape($sStr) {
    	global $gGlobals;
        if(MYSQL_USE_MYSQLI)
        	return mysqli_real_escape_string ($this->conn,$sStr);
        else
        	return mysql_real_escape_string($sStr,$this->conn);
    }

    function affectedRows() {
    	global $gGlobals;
    	if(MYSQL_USE_MYSQLI)
    		return @mysqli_affected_rows($this->conn);
    	else
    		return @mysql_affected_rows($this->conn);
    }

function selectdb($sTablePrefix = "", $sDatabase = "") {
    global $gGlobals;

    if(empty($sDatabase))
    	$sDatabase = $gGlobals['database']['name'];

    if($sDatabase == $this->sCurrentDB)
    	return;

    $this->sTablePrefix = $sTablePrefix;

    if(empty($sTablePrefix))
    	$this->sTablePrefix = $gGlobals['database']['prefix'];

        if(MYSQL_USE_MYSQLI)
        @mysqli_select_db($this->conn,$sDatabase) or reportError($this);
        else
		@mysql_select_db($sDatabase,$this->conn) or reportError($this);
	$this->sDatabaseName = $sDatabase;
}

function query($str, $bDie = true, $bHideError = false) {
    global $gGlobals;

	if(empty($str))
		return 0;
        if(MYSQL_USE_MYSQLI) {
        $result = mysqli_query($this->conn,$str) or reportError($this,$str,$bHideError,false,$bDie);
        } else {
		$result = mysql_query($str,$this->conn) or reportError($this,$str,$bHideError,false,$bDie);
        }

	if(MIPHOTO_DEV) {
		$this->iNumQueries++;
		$this->aQueries[] = $str;
	}

	return ($result);
}

function alterTable($sTable, $sParams) {
	$sQuery = "ALTER TABLE {$this->sTablePrefix}_{$sTable} {$sParams}";

	return $this->query($sQuery);
}

function select($sWhat,$table,$params="",$order="") {
    	global $gGlobals;

	if(empty($sWhat)||empty($table))
		return 0;

	if(!empty($params))
		$params = " WHERE ".$params;

	$sQuery = "SELECT {$sWhat} FROM {$this->sTablePrefix}_{$table}{$params} {$order}";

	if(MIPHOTO_DEV) {
		$this->iSelectQueries++;
		$this->aQueriesPerTable[$table]++;
	}

	return $this->query($sQuery);
}

function selectMultiple($aArray,$params="",$order="", $bCountOnly = false /*, $bEcho = false */) {
	/*

		format of array for $aArray parameter

		$aArray = Array(
							Array(
									'table'	=>	The table name
									'alias'	=>	The alias for the table
									'select'	=>	Array( What to select from this table )
								)
							...
						)
	*/


    	global $gGlobals;

    	$sTables = $sSelect = "";

    	$bMore = true;

    	if(!is_array($aArray))
    		return 0;

    	foreach($aArray as $aTable) {
    		if(empty($aTable['table']) || empty($aTable['alias']))
    			return 0;

		$sTables .= "{$this->sTablePrefix}_{$aTable['table']} AS {$aTable['alias']}";

		if(isset($aTable['useindex']) && !empty($aTable['useindex'])) {
			$sTables .= " USE INDEX ({$aTable['useindex']})";
		}

		$sTables .= ",";

		if(MIPHOTO_DEV) {
			$this->aQueriesPerTable[$aTable['table']]++;
		}

		if(!is_array($aTable['select'])) {
			// The select is a string, not an array
			// Lets parse the select string into an array
			$aTable['select'] = explode(",",$aTable['select']);
		}

		foreach($aTable['select'] as $sTableSelect) {
			if(!$bMore)
				continue;
			if($sTableSelect == "COUNT(*)" || $sTableSelect == "COUNT(id)" || $bCountOnly) {
				$sSelect .= "COUNT(*),";
				$bMore = false;
			} elseif(!$bCountOnly) {
				$sSelect .= "{$aTable['alias']}.{$sTableSelect},";
			}

		}
    	}

    	$sTables = substr($sTables,0,-1);
    	$sSelect = substr($sSelect,0,-1);

	if(empty($sSelect) || empty($sTables))
		return 0;
	if(!empty($params))
		$params = " WHERE ".$params;

	$sQuery = "SELECT {$sSelect} FROM {$sTables} {$params} {$order}";

	if(MIPHOTO_DEV) {
		$this->iSelectQueries++;
	}
/*
	if($bEcho)
		echo $sQuery;
*/

	return ($this->query($sQuery));
}

function getRow($result,$bFreeResult = false) {
        global $gGlobals;
    if(MYSQL_USE_MYSQLI) {
    	$sReturn = @mysqli_fetch_array($result,MYSQLI_ASSOC);
    } else {
		$sReturn = @mysql_fetch_array($result,MYSQL_ASSOC);
        }

        if($bFreeResult) {
        	$this->freeResult($result);
        }

        return $sReturn;
}

    function getResult($result,$offset=0) {
        global $gGlobals;
    if(MYSQL_USE_MYSQLI) {
        @mysqli_data_seek($result,$offset);
            $row = @mysqli_fetch_row($result);
            $this->freeResult($result);
        return $row[0];
        } else {
    	$sReturn = @mysql_result($result,$offset);

    	$this->freeResult($result);
    	return $sReturn;
        }
    }

    function setRowSeek($rResult, $iRow) {
    	if(MYSQL_USE_MYSQLI) {
    		return mysqli_data_seek($rResult,$iRow);
    	} else {
    		return mysql_data_seek($rResult,$iRow);
    	}
    }

function getRowCount($result) {
        global $gGlobals;
    if(MYSQL_USE_MYSQLI)
        return @mysqli_num_rows($result);
        else
		return @mysql_num_rows($result);
}

function freeResult($result) {
        global $gGlobals;
    	if(MYSQL_USE_MYSQLI)
        return @mysqli_free_result($result);
        else
		return @mysql_free_result($result);
}

function getInsertId() {
        global $gGlobals;
        if(MYSQL_USE_MYSQLI)
        return @mysqli_insert_id($this->conn);
        else
		return @mysql_insert_id($this->conn);
}

function version($bArray = true) {
	global $gGlobals;

	if(!empty($this->db_version)) {
		return $this->db_version;
	}

	if(MYSQL_USE_MYSQLI)
		$this->db_version = @mysqli_get_server_info($this->conn);
	else
		$this->db_version = @mysql_get_server_info($this->conn);

	if($bArray)
		return explode(".",$this->db_version);

	return $this->db_version;
}

function getErrorNumber($bOnConnect = false) {
	global $gGlobals;
	if(MYSQL_USE_MYSQLI) {
		if($bOnConnect) {
			return mysqli_connect_errno($this->conn);
		} else {
			return mysqli_errno($this->conn);
		}
	} else {
		if($this->conn)
			return mysql_errno($this->conn);
		else
			return mysql_errno();
	}
}

function getErrorMessage($bOnConnect = false) {
	global $gGlobals;
	if(MYSQL_USE_MYSQLI) {
		if($bOnConnect) {
			return mysqli_connect_error();
		} else {
			return mysqli_error($this->conn);
		}
	} else {
		if($this->conn)
			return mysql_error($this->conn);
		else
			return mysql_error();
	}
}

function getDefaultTimeStamp() {
	$aMySQLVersion = $this->version(true);

	// See if version is >= 4.1.2
	if(($aMySQLVersion[0] == 4 && $aMySQLVersion[1] >= 1 && $aMySQLVersion[2] >= 2) || ($aMySQLVersion[0] >= 5)) {
		//$sDefaultCurrentTimeStamp = " DEFAULT '0'";
		$sDefaultCurrentTimeStamp = "";
		$sDefaultCurrentTimeStampOnUpdate = " DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP";
	}
	elseif($aMySQLVersion[0] == 4 && $aMySQLVersion[1] == 0 && $aMySQLVersion[2] == 17) {
		// This version seems to only work with this...
		$sDefaultCurrentTimeStamp = $sDefaultCurrentTimeStampOnUpdate = "";
	} else {
		$sDefaultCurrentTimeStamp = $sDefaultCurrentTimeStampOnUpdate = " DEFAULT 0";
	}

	return array('current_timestamp' => $sDefaultCurrentTimeStamp, 'on_update' => $sDefaultCurrentTimeStampOnUpdate);
}
}

function reportError($oDb, $sQuery = "", $bHideError = false, $bOnConnect = false, $bDie = true) {
    if(!$bHideError) {
    echo "<table><tr><th>Error: ";

    echo $oDb->getErrorNumber($bOnConnect);

    echo "</th></tr><tr><td class='col2'>";

    echo $oDb->getErrorMessage($bOnConnect);

    echo "</th></tr><tr><td>{$sQuery}</td></tr></table>";
    }

    if($bDie) {
    if($oDb->conn)
		$oDb->disconnect();
	die();
    }
}

?>

Share this post


Link to post
Share on other sites

I have solved my problem now, all I had to do was change the $iUser to $iStart and it is now solved  :)

Share this post


Link to post
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.