Jump to content

[SOLVED] php mysql array


dlf1987

Recommended Posts

trying to create mysql array...

 

i commented right where the problem is

 

 

<?php
mysql_select_db($database_pixeldecal, $pixeldecal);
$query_rsIP = "SELECT * FROM settings";
$rsIP = mysql_query($query_rsIP, $pixeldecal) or die(mysql_error());
$row_rsIP = mysql_fetch_assoc($rsIP);
$totalRows_rsIP = mysql_num_rows($rsIP);

	do {	
		$blockips .= '"'.$row_rsIP['settings_value'].'", ';		
	} while ($row_rsIP = mysql_fetch_assoc($rsIP));

	$blockips=substr($blockips,0,-2);	
	if ($blockips == '') $blockips = 0;


// STUCK RIGHT HERE 
// TRYING TO FIGURE OUT HOW TO ADD VALUES TO THE ARRAY BELOW
// HERES WHAT THE ABOVE MYSQL QUERY CREATES - "74.240.1.000", "74.120.113.00"
// BUT THAT DOESNT WORK 
// IF I COPY AND PASTE THOSE VALUES STRAIGHT INTO THE ARRAY BELOW IT WORKS FINE THOUGH


$include = array($blockips);
if (in_array($_SERVER['REMOTE_ADDR'], $include) == false) {
	echo $blockips;
	// Crazy Egg
	echo '
	<script type="text/javascript" src="https://cetrk.com/pages/scripts/0000/XXXX.js"></script>
	';
	// Google Analytics
	echo '
	<script src="https://ssl.google-analytics.com/urchin.js" type="text/javascript"></script>
	<script type="text/javascript">
	_uacct = "UA-XXXXX-2";
	urchinTracker();
	</script>
	';
}
mysql_free_result($rsIP);
?>

 

Thanks,

Daniel

Link to comment
Share on other sites

ummmm i think theres a misunderstanding... forget the example i gave you.... try this

 

im not having trouble with the substr, its the values that im putting into the array, thats not working...

 

this works

<?php
$include = array("74.000.1.168", "74.000.113.72");
if (in_array($_SERVER['REMOTE_ADDR'], $include) == true) { echo ""; }
?>

 

but this doesnt

<?php

$blockips = '"74.000.1.168", "74.000.113.72"';

$include = array($blockips);
if (in_array($_SERVER['REMOTE_ADDR'], $include) == true) { echo ""; }
?>

Link to comment
Share on other sites

thats still not what im looking for  :(

 

I'm trying to hide my website stats scripts based on the ip's i have listed in my mysql database... is there another way of doing this?

 

another words...

if your ip matches the mysql query ip, don't echo stat scripts...

 

Thanks!

Link to comment
Share on other sites

its MUCH easier to let mysql handle blocked ip's...

 

<?php
$query=mysql_query("SELECT * FROM `banned` WHERE `ip`='$_SERVER['REMOTE_ADDR']' LIMIT 1");
if(mysql_num_rows($query)>0) die("you've been banned... GO AWAY! lol");
?>

Link to comment
Share on other sites

well the thing is, i'm not trying to ban those ip's. Its my work ip, home ip, and a couple of others ip's that i don't want to be included in my sites statistics. another words if i go to my site, i don't want my google Analytics, and crazy egg scripts to show... hope that makes sense... sorry

Link to comment
Share on other sites

perfect sense... but still a similar fix... lol

 

<?php

$query=mysql_query("SELECT * FROM `banned` WHERE `ip`='$_SERVER['REMOTE_ADDR']' LIMIT 1");

if(mysql_num_rows($query)==0){

echo '<script type="text/javascript" src="https://cetrk.com/pages/scripts/0000/XXXX.js"></script>';

echo '<script src="https://ssl.google-analytics.com/urchin.js" type="text/javascript"></script> <script type="text/javascript">_uacct = "UA-XXXXX-2";urchinTracker();</script>';

}

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.