jazz00006 Posted February 7, 2007 Share Posted February 7, 2007 Hey, I'm using the following lines of code to get the submitted IP(s) and place them in a database $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 and i've tried without the /r ect $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(); } } however, when i try to find a certain IP $result = mysql_query("SELECT * FROM `tempbase` WHERE `IP` = '".$_GET['IP']."';", $sql); it doesnt find it, and when i edit the database under phpmyadmin it ends up giving me somthing like 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 ; and then when i try to find the IP using the PHP as above, it works. 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 code as posted above? Quote Link to comment https://forums.phpfreaks.com/topic/37429-phpmysql-not-submitting-data-correctly-after-splitting-exploding/ Share on other sites More sharing options...
jazz00006 Posted February 7, 2007 Author Share Posted February 7, 2007 sorry guys, i feel ashamed, can some one please move this topic to the PHP help forum (I guess i should have looked more carefully before posting) Quote Link to comment https://forums.phpfreaks.com/topic/37429-phpmysql-not-submitting-data-correctly-after-splitting-exploding/#findComment-178970 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.