instant Posted October 27, 2010 Share Posted October 27, 2010 i have installed a script and connected databse to script but still its giving error My website url = http://tinyurl.com/2wso6kl error its giving is Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/revolut1/public_html/adsensesafetraffic/statistics_Adzmedia/php/get_site.php on line 16 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/revolut1/public_html/adsensesafetraffic/statistics_Adzmedia/index.php on line 121 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/revolut1/public_html/adsensesafetraffic/statistics_Adzmedia/index.php on line 133 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/revolut1/public_html/adsensesafetraffic/statistics_Adzmedia/index.php on line 135 My website url = http://tinyurl.com/2wso6kl getsite.php code = <? ############################################################################################################## ######################################### GETTING SITE INFORMATIONS FROM DATABSE ############################# $q_get_site_info="select * from table_siteinfo where siteinfo_key='$_SESSION[CKL]' or siteinfo_key = 1 order by siteinfo_key"; $r_get_site_info=make_query($q_get_site_info); /* if(mysql_num_rows($r_get_site_info)!=2){ $CKL=1; $q_get_site_info="select * from table_siteinfo where siteinfo_key='$CKL' or siteinfo_key = 1 order by siteinfo_key"; $r_get_site_info=make_query($q_get_site_info); } */ while($field_get_site_info=mysql_fetch_array($r_get_site_info)){ if($field_get_site_info[siteinfo_key]==1){ $PATH=$field_get_site_info[siteinfo_url]; $ENCRYPT_KEY=$field_get_site_info[siteinfo_encrypt_key]; $LOCALPATH=$field_get_site_info[siteinfo_localpath]; $ERROR=$field_get_site_info[siteinfo_error]; $REDIRECT_URL=$field_get_site_info[siteinfo_redirect_url]; $REDIRECT_ENABLED=$field_get_site_info[siteinfo_redirect_enabled]; $SITENAME=$field_get_site_info[siteinfo_name]; $SUPPORT_ADDRESS=$field_get_site_info[siteinfo_support_email]; $STYLE=$field_get_site_info[siteinfo_style]; $REC_COUNT=$field_get_site_info[siteinfo_rec_count]; $LOGO=$field_get_site_info[siteinfo_logo]; $RESELLERPATH=$field_get_site_info[siteinfo_reseller_url]; $MESSAGE=$field_get_site_info[siteinfo_message]; } else{ $SITENAME=$field_get_site_info[siteinfo_name]; $SUPPORT_ADDRESS=$field_get_site_info[siteinfo_support_email]; $STYLE=$field_get_site_info[siteinfo_style]; $REC_COUNT=$field_get_site_info[siteinfo_rec_count]; $LOGO=$field_get_site_info[siteinfo_logo]; $RESELLERPATH=$field_get_site_info[siteinfo_reseller_url]; $MESSAGE=$field_get_site_info[siteinfo_message]; } } ?> index.php code= <? error_reporting(E_ALL ^E_NOTICE); #phpinfo(); ################################################################# # Enterprise Traffic Server v3 # # Copyright 2002 TurnkeyTraffic.com # # This software MAY NOT be redistributed in ANY format. # # You are licensed ONE copy of software for use on ONE website. # # Violaters will be prosecuted to the fullest extent of the law.# ################################################################# ############################################################################################################## #################################### INCLUDING FUNCTIONS, CONNECTING AND GENERAL SETTINGS ################### include("config/config.inc.php"); session_name ("TR_SK"); session_start(); connectdb(); $call_tracker=0; ############################################################################################################## ############################################ FIXING MAGIC QUOTES ISSUE ############################### if (get_magic_quotes_gpc()) { // do nothing; } else{ foreach($_GET as $k=>$v){ $_GET[$k] = doaddslashes($v); $$k = $_GET[$k]; } foreach($_POST as $k=>$v){ $_POST[$k] = doaddslashes($v); $$k = $_POST[$k]; } foreach($_COOKIE as $k=>$v){ $_COOKIE[$k] = doaddslashes($v); $$k = $_COOKIE[$k]; } //echo get_magic_quotes_gpc(); ini_set("magic_quotes_gpc",1); //echo get_magic_quotes_gpc(); } ############################################################################################################## ############################################ CHECK TO SEE IF TRACKER IS CALLED ############################### if(preg_match("/TRCK=/",base64_decode($_SERVER['QUERY_STRING']))){ $type="group"; $call_tracker=1; } elseif(preg_match("/TRCKAD=/",base64_decode($_SERVER['QUERY_STRING']))){ $type="ad"; $call_tracker=1; } ############################################################################################################## ################################################### CALL THE TRACKER ######################################### if($call_tracker==1){ include("php/tracker.php"); exit; } ############################################################################################################## ####################################### SETTING SESSION FOR RESELLER USAGE ################################### if(isset($_SESSION['CKL']) || isset($_GET['logout'])){ $_SESSION['CKL']=''; } else{ $_SESSION['CKL']=1; } ############################################################################################################## ################################################### GET SITE DATA ############################################ include("php/get_site.php"); ############################################################################################################## ##################### CHECKING SESSION VARIABLES AND GETTING USER DETAILS ################################### $id_sess = $_SESSION['id_sess']; $user_sess = $_SESSION['user_sess']; $pass_sess = $_SESSION['pass_sess']; if($id_sess){ $q="select * from table_logins where logins_key='$id_sess' and logins_username='$user_sess' and logins_password = '$pass_sess' and logins_active=1"; $r=make_query($q); $MY=mysql_fetch_array($r); if(@mysql_num_rows($r) > 0){ $MY[ACCESS]=$MY[logins_type]; } else { session_destroy(); } } else{ $MY[ACCESS]=-1; } ############################################################################################################## ############################################# GETTING SITE MESSAGES FROM DATABASE ############################ if(is_array(($_SESSION['SESSION_MSG'])) && sizeof($_SESSION['SESSION_MSG'])){ foreach($_SESSION['SESSION_MSG'] as $r=>$t){ $msg[$r]=$t; } } else{ $q="select * from table_msg"; $r=make_query($q); $_SESSION['SESSION_MSG']=array(); while($field=mysql_fetch_array($r)){ $msg[$field[msg_key]] = $field["msg_text"]; $_SESSION['SESSION_MSG'][$field[msg_key]]=$field["msg_text"]; } } ############################################################################################################## $inl = $_GET['inl']; if(!$inl){$inl="home";} $q_check="select * from table_access where access_page='$inl'"; $r_check=make_query($q_check); $field_check=mysql_fetch_array($r_check); if(mysql_num_rows($r_check)){ if($field_check[access_title]){ $title=$field_check[access_title]; } else{ $title=$SITENAME; } starting($title); if($field_check[access_type] > $MY[ACCESS]){ if($MY[ACCESS]){$err="admin_only";} $inl="login"; } include("php/$inl.php"); $xtpl->parse("mainpage.doublesection.$inl"); $xtpl->parse("mainpage.doublesection"); ######################### ending(); } ?> config code= <? ################################ DB CONNECTING ############################################################### function connectdb(){ include "config/dbconnect.inc.php"; $conn=mysql_connect($location,$user,$password); echo mysql_error(); mysql_select_db($database,$conn); echo mysql_error(); if(mysql_error()){exit;} } ################################## CHECKS USER IN SESSION AND DATABASE AND REDIRECTS HIM ##################### function redirect_user($TYPE=0){ global $cook_user,$id_sess; $ref=base64_encode("http://$_SERVER[sERVER_NAME]$_SERVER[php_SELF]?$_SERVER[QUERY_STRING]"); $err="err2"; header("Location: $PATH/?inl=login&".SID."&err=$err&ref=$ref");exit; } ############################################################################################################# ########################################### SEND EMAIL ###################################################### function send_email($recipient,$subject,$message){ global $SUPPORT_ADDRESS,$SITENAME,$PATH,$ADMIN,$STYLE,$LOGO,$RESELLERPATH; $subject=preg_replace("/{SITENAME}/",$SITENAME,$subject); $subject=preg_replace("/{SUPPORT_ADDRESS}/",$SUPPORT_ADDRESS,$subject); $subject=preg_replace("/{PATH}/",$PATH,$subject); $subject=preg_replace("/{LOGO}/",$LOGO,$subject); $subject=preg_replace("/{RESELLERPATH}/",$RESELLERPATH,$subject); $subject=preg_replace("/{ADMIN}/",$ADMIN,$subject); $message=preg_replace("/{SITENAME}/",$SITENAME,$message); $message=preg_replace("/{SUPPORT_ADDRESS}/",$SUPPORT_ADDRESS,$message); $message=preg_replace("/{PATH}/",$PATH,$message); $message=preg_replace("/{LOGO}/",$LOGO,$message); $message=preg_replace("/{RESELLERPATH}/",$RESELLERPATH,$message); $message=preg_replace("/{ADMIN}/",$ADMIN,$message); $headers .= "From: \"$SITENAME\" <$SUPPORT_ADDRESS>\n"; $headers .= "X-Sender:\n"; $headers .= "X-Mailer: PHP\n"; // mailer $headers .= "Return-Path: $ADMIN\n"; // Return path for errors $headers .= "Content-Type: text/html; charset=iso-8859-1\n"; // Mime type $message="<body><style type='text/css'>$STYLE</style>".$message; $message.="</body>"; @mail($recipient, $subject, $message, $headers); } ############################################################################################################# ################### FUNCTIONS FOR BEGINING AND ENDING A PAGE (1 FOR MEMBER PAGES TO REDIRECT) ############### function starting($title=""){ global $xtpl,$PATH,$id_sess,$STYLE,$LOGO,$MESSAGE,$MY; require("config/xtpl.p"); // h4h if ($MY[ACCESS] == 2) { $xtpl=new XTemplate("template/main_a.html"); } else { $xtpl=new XTemplate("template/main.html"); } // h4h $xtpl->assign("TITLE",$title); $xtpl->assign("LOGO",$LOGO); $xtpl->assign("PATH",$PATH); $xtpl->assign("MESSAGE",$MESSAGE); $xtpl->assign("SID",SID); $xtpl->assign("ID_SESS",$id_sess); $xtpl->assign("style","$STYLE"); $xtpl->assign("admintext","$field[messages_text] - $field[date]"); if($MY[ACCESS]==1 || $MY[ACCESS]==2){ $xtpl->parse("mainpage.topsection.is_logged_1_2.features_$MY[ACCESS]"); if($MY[ACCESS]==2)$xtpl->parse("mainpage.topsection.is_logged_1_2.groups"); $xtpl->parse("mainpage.topsection.is_logged_1_2"); } elseif($MY[ACCESS]==0){ $xtpl->parse("mainpage.topsection.is_logged_0"); } $xtpl->parse("mainpage.topsection"); } function ending($sponsors=""){ global $xtpl,$id_sess,$LANG; $xtpl->parse("mainpage.botsection"); $xtpl->parse("mainpage"); $xtpl->out("mainpage"); } ############################################################################################################# ###################### MAKE A QUERY RETURN ERROR AND DIE; USED TO MAKE THE COUNT AS WELL #################### function make_query($query_content,$fields="",$if_count=0){ global $ERROR; $query_content=preg_replace("/##fields##/",$fields,$query_content); if($if_count){ $query_content=preg_replace("/limit \d+/i","limit 0",$query_content);#echo $query_content; } $query_content=preg_replace("/##/","",$query_content); $result=mysql_query($query_content); if($ERROR=="on" && mysql_error()){ die("$query_content<br><br><b><font color=red>".mysql_error()); } #echo "<br><br>\n\n$query_content\n\n<br><br>"; return $result; } ####################### FIXING STRINGS ############################# function fix_strings($var,$and_slashes=1){ if(is_array($var)){ foreach ($var as $i=>$v){ if($and_slashes)$var[$i]=stripslashes($var[$i]); $var[$i]=htmlentities($var[$i], ENT_QUOTES);#echo $arr[$i],"<br>"; } } else{ if($and_slashes)$var=stripslashes($var); $var=htmlentities($var, ENT_QUOTES);#echo $var,"<br>"; } return $var; } ##################################################################### ############################################################################################################# function demo_out(){ global $MY,$PATH; if($MY[logins_demo]){ Header("Location: $PATH/?inl=messages&mess=17&".SID);exit; } } function doaddslashes($VAR){ if(is_array($VAR)){ foreach($VAR as $i=>$v){ $VAR[$i]=doaddslashes($VAR[$i]); } } else{ $VAR=addslashes($VAR); } return $VAR; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/216965-mysql-error-pls-help/ Share on other sites More sharing options...
trq Posted October 27, 2010 Share Posted October 27, 2010 Whatever this script is meant to do, I'd find another one. This is some of the worst code I've seen in a long while. Quote Link to comment https://forums.phpfreaks.com/topic/216965-mysql-error-pls-help/#findComment-1127048 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.