/    Sign up×
Community /Pin to ProfileBookmark

My website url = [url]http://tinyurl.com/2wso6kl[/url]

Im getting this error
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

===============================================
these are lines of php where error is found

while($field_get_site_info=mysql_fetch_array($r_get_site_info)){

while($field=mysql_fetch_array($r)){

$field_check=mysql_fetch_array($r_check);

if(mysql_num_rows($r_check)){

to post a comment
PHP

17 Comments(s)

Copy linkTweet thisAlerts:
@devel95Oct 26.2010 — Please provide more snippits of your code, especially the query select statement(s).
Copy linkTweet thisAlerts:
@instantauthorOct 26.2010 — getsite.php code

[code=php]<?
##############################################################################################################
######################################### 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];

}

}

?>[/code]


index.php code
[code=php]<? 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();

}
?>

[/code]
Copy linkTweet thisAlerts:
@instantauthorOct 26.2010 — index.php code =
[code=php]<? 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();

}
?>

[/code]


getsite.php code =
[code=php]<?
##############################################################################################################
######################################### 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];

}

}

?>
[/code]
Copy linkTweet thisAlerts:
@devel95Oct 26.2010 — getsite.php code

[code=php]<?
##############################################################################################################
######################################### 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);

[/code]
[/QUOTE]


Show us a copy of your make_query() function. Is that where you are connecting to your database?
Copy linkTweet thisAlerts:
@instantauthorOct 26.2010 — config file is ,
[code=php]<?
$user = "username";
$password = "password";
$database = "database";
$location = "location usually localhost";
?>[/code]
Copy linkTweet thisAlerts:
@instantauthorOct 26.2010 — if u need to see more php codes ,

here is the complete script , please let me know how to fix the error

http://rapidshare.com/files/427197873/statistics.zip
Copy linkTweet thisAlerts:
@instantauthorOct 26.2010 — sir please let me know if u need to see more php code ,

i do not know why it is not running .
Copy linkTweet thisAlerts:
@devel95Oct 26.2010 — Honestly, I am hesitant to download anything foreign (like this) for risk of damaging my machine.

Can you extract and post your make_query() function? Just the part that does the connection to the database and the query selection.

Then I can look at it and see if I am able to offer any assistance.
Copy linkTweet thisAlerts:
@instantauthorOct 26.2010 — i do not know what is make query function ? thats y i attached script file ,

there is no virus in the script ,

which page code should i paste here
Honestly, I am hesitant to download anything foreign (like this) for risk of damaging my machine.

Can you extract and post your make_query() function? Just the part that does the connection to the database and the query selection.

Then I can look at it and see if I am able to offer any assistance.[/QUOTE]
Copy linkTweet thisAlerts:
@instantauthorOct 26.2010 — this is config file that connects to database

<?

$user = "username";

$password = "password";

$database = "database";

$location = "location usually localhost";

?>
Copy linkTweet thisAlerts:
@instantauthorOct 26.2010 — config.inc file
[code=php]<?
################################ 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: PHPn"; // mailer
$headers .= "Return-Path: $ADMINn"; // Return path for errors
$headers .= "Content-Type: text/html; charset=iso-8859-1n"; // 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>nn$query_contentnn<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;
}

?>
[/code]
Copy linkTweet thisAlerts:
@devel95Oct 26.2010 — Ok, you got it...config.inc contains your make_query() function.

I will try to take a look (and maybe other viewers will do the same) but it is nearing the end of my day here so I may need to revisit tomorrow.

Not all it lost -- what you have just posted will enable "experienced" technicians to dig deeper to assist.
Copy linkTweet thisAlerts:
@instantauthorOct 27.2010 — can any one please look into my issue , i will be really thank ful to those who can help me
Copy linkTweet thisAlerts:
@criterion9Oct 27.2010 — 
$result=mysql_query($query_content);

if($ERROR=="on" && mysql_error()){

die("$query_content<br><br><b><font color=red>".mysql_error());

}

#echo "<br><br>nn$query_contentnn<br><br>";

return $result;
[/quote]


You need to set "$ERROR=on;" wherever you are setting $ERROR. The message you are getting is because there is an error in your query and thus the "$result" is false instead of a result resource.

The above could be simplified (though I recommend logging the error and gracefully exiting in production):
[code=php]
$result=mysql_query($query_content);
if(!$result){
die("$query_content<br><br><b><font color=red>".mysql_error());
} else {
return $result;
}
[/code]
Copy linkTweet thisAlerts:
@whirlwindOct 27.2010 — Shouldn't it be 'mysql_query' on line 16 of get_site.php instead of 'make_query'?
Copy linkTweet thisAlerts:
@criterion9Oct 28.2010 — Shouldn't it be 'mysql_query' on line 16 of get_site.php instead of 'make_query'?[/QUOTE]

Not in this case. make_query is a custom function that also happens to use mysql_query.
Copy linkTweet thisAlerts:
@whirlwindOct 28.2010 — Thanks criterion9!
×

Success!

Help @instant spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.4,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...