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
https://forums.phpfreaks.com/topic/53360-solved-php-mysql-array/
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 ""; }
?>

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

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>';

}

?>

Archived

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

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