Hey, me again, I'm using the following lines of code to get the submitted IP(s) and place them in a database
however, when i try to find a certain IP
it doesnt find it, and when i edit the database under phpmyadmin it ends up giving me somthing likePHP Code:$result = mysql_query("SELECT * FROM `tempbase` WHERE `IP` = '".$_GET['IP']."';", $sql);
I'm guessing that this has something to do with the encoding and the \r at the end of the IP field, how can i implement that when i submit the data using the following snippetCode:UPDATE `tempbase` SET `IP` = '123.123.123.1' WHERE CONVERT( `tempbase`.`IP` USING utf8 ) = '123.123.123.1\r' AND CONVERT( `tempbase`.`Email` USING utf8 ) = '' AND CONVERT( `tempbase`.`Reason` USING utf8 ) = '' AND CONVERT( `tempbase`.`Log` USING utf8 ) = 'Temp_Logs/February-4-2007-8-21-00-am.' AND CONVERT( `tempbase`.`spare` USING utf8 ) = '219-90-252-115.ip.adam.com.au' AND CONVERT( `tempbase`.`Uid` USING utf8 ) = 'WBCSNRMUHF-CYAWRNMKWO' LIMIT 1 ;
PHP Code:$UID = randomkey(10).'-'.randomkey(10);
$counterMax = substr_count($_POST['IP'],"\r\n");
for ( $counter = 0; $counter <= $counterMax; $counter += 1) {
$sql = mysql_connect($GLOBALS["dbhost"], $GLOBALS["dbuser"], $GLOBALS["dbpass"]);
$dbHandle = mysql_select_db($GLOBALS["dbname"]);
$EMAIL = mysql_real_escape_string($_POST['EMAIL']);
$REASON = mysql_real_escape_string($_POST['REASON']);
$LOG = mysql_real_escape_string($target_path);
$SPARE = gethostbyaddr($_SERVER['REMOTE_ADDR']);
$IP = preg_split("/[\n,]+/", $_POST['IP'], -1, PREG_SPLIT_OFFSET_CAPTURE);
$NewIP = str_replace(' ','',mysql_real_escape_string($IP[$counter][0]));
$NewIP = $NewIP."\r"; //I tried the \r part, but it doesnt make and difference
$sql = "INSERT INTO `$DB` ( `IP` , `Email` , `Reason` , `Log` , `spare` , `Uid` )
VALUES (
'$NewIP', '$EMAIL', '$REASON', '$LOG', '$SPARE' ,'$UID'
);";
$result = mysql_query($sql);
mysql_close($sql);
if (is_resource($rows)) {
} else {
echo mysql_error();
}
}


Reply With Quote