NLCJ Posted September 19, 2010 Share Posted September 19, 2010 Hello, I've been working on some stuff, and get the information parsed like this: Value1,Value2,Value3 0.68,4377.54,11069.02 So I'm trying to explode it and insert the latest numbers into the database. I'm using: $value = explode(",", $variable); $secondsplit = explode(" ", $value[2]); mysql_query("INSERT INTO table(row) VALUES('".mysql_real_escape_string($secondsplit[1])."')"); The problem is that it has something like an enter in the database, or a space. But I can't figure out how to get rid of that problem. Does anyone know what's wrong? Regards, NLCJ Quote Link to comment https://forums.phpfreaks.com/topic/213819-explode-doesnt-work/ Share on other sites More sharing options...
NLCJ Posted September 19, 2010 Author Share Posted September 19, 2010 This is in the source code if I print it: 0.68 I've got no idea what it is?! It isn't a <br> or a space or a \r\n... Maybe important: I fetch the information using cURL. Quote Link to comment https://forums.phpfreaks.com/topic/213819-explode-doesnt-work/#findComment-1112889 Share on other sites More sharing options...
taquitosensei Posted September 19, 2010 Share Posted September 19, 2010 should it be this $string="Value1,Value2,Value3 0.68,4377.54,11069.02" $exp1=explode(" ", $string); $fields=explode(",", $exp1[0]); $values=explode(",", $exp1[1]); mysql_query("INSERT INTO table(row) VALUES('".mysql_real_escape_string($values[0])."')"); // 1 if you want the 2nd value, 2 if you want the 3rd Quote Link to comment https://forums.phpfreaks.com/topic/213819-explode-doesnt-work/#findComment-1112892 Share on other sites More sharing options...
NLCJ Posted September 19, 2010 Author Share Posted September 19, 2010 Doesn't work, somehow there is an 'enter' but I'm not able to explode it... Quote Link to comment https://forums.phpfreaks.com/topic/213819-explode-doesnt-work/#findComment-1112897 Share on other sites More sharing options...
NLCJ Posted September 19, 2010 Author Share Posted September 19, 2010 I might have a clue, I think it's the 'invisible character'... What dumbass invented that?! Quote Link to comment https://forums.phpfreaks.com/topic/213819-explode-doesnt-work/#findComment-1112908 Share on other sites More sharing options...
PFMaBiSmAd Posted September 19, 2010 Share Posted September 19, 2010 You should almost always use trim on data to eliminate white-space characters surrounding it. Quote Link to comment https://forums.phpfreaks.com/topic/213819-explode-doesnt-work/#findComment-1112913 Share on other sites More sharing options...
NLCJ Posted September 19, 2010 Author Share Posted September 19, 2010 Thanks a lot, really! This took me about 9 hours of searching before I figured out that there is an invisible character! Once again thanks! Quote Link to comment https://forums.phpfreaks.com/topic/213819-explode-doesnt-work/#findComment-1112918 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.