Nicholas Posted February 9, 2010 Share Posted February 9, 2010 hi, im having a huge problem and cant figure out why its happening! say someone on my game puts hi, welcome to blah blah the requirements to join is the following... strength, agility, defence in hall of fame active daily but some reason it comes out like this hi, welcome to blah blah the requirements to join is the following... strength, agility, defence in hall of fame active daily it doesnt allow enter bars (drop down a line) any idea why it would be doing this? Quote Link to comment Share on other sites More sharing options...
Zeggy Posted February 9, 2010 Share Posted February 9, 2010 Use the nl2br() function to add newlines. Quote Link to comment Share on other sites More sharing options...
Nicholas Posted February 9, 2010 Author Share Posted February 9, 2010 never heard of that function lol. is it like this stuff? < br /> and /n if so, that doesnt work nither just says this when i try changing my gang description hi, welcome test do you think it could be something to do with the server? Quote Link to comment Share on other sites More sharing options...
Mr-Anthony Posted February 9, 2010 Share Posted February 9, 2010 Lol, have you tryed useing html with it. Quote Link to comment Share on other sites More sharing options...
Zeggy Posted February 9, 2010 Share Posted February 9, 2010 Well, it might not work depending on where you are using it. I assumed you'd be using it when you output the text on a web page. nl2br() converts all your new lines into tags so if you output text with newlines on an html page, it will display correctly. If you're displaying it in a text field, of course it will show , html is not rendered in form fields. Also, if you are using code like htmlentities after you use nl2br, it will convert all the < and > to html entities. Quote Link to comment Share on other sites More sharing options...
Nicholas Posted February 9, 2010 Author Share Posted February 9, 2010 its doing it for everything... gang description mailbox messages profile signiture usershops description and blah blah... i never edited anything so i have no idea why its doing it... i do keep on thinking its something to do with the server. Quote Link to comment Share on other sites More sharing options...
Nicholas Posted February 9, 2010 Author Share Posted February 9, 2010 ahh ha i think i figured the bloody thing out! i added this to globals.php function anti_inject($campo) { foreach($campo as $key => $val) { $val = mysql_real_escape_string($val); // store it back into the array $campo[$key] = $val; } return $campo; //Returns the the var clean } //the next two lines make sure all post and get vars are filtered through this function $_POST = anti_inject($_POST); $_GET = anti_inject($_GET); Quote Link to comment Share on other sites More sharing options...
Magictallguy Posted February 11, 2010 Share Posted February 11, 2010 That's a security fail - that won't help you. Wrapping the output in nl2br() would help you here. Quote Link to comment Share on other sites More sharing options...
Zero-Affect Posted February 11, 2010 Share Posted February 11, 2010 Yeah Epic fail! Why do people assume these horrid scripts will work, seriously. Quote Link to comment Share on other sites More sharing options...
SlanderDesign Posted February 15, 2010 Share Posted February 15, 2010 Yeah Epic fail! Why do people assume these horrid scripts will work, seriously. Why criticize? Why don't you help him so he don't make the mistake again? It really isn't fun for him to be laughed at... You guys are "Epic" But for new people it's hard...Teach them the way! :P Quote Link to comment Share on other sites More sharing options...
Zero-Affect Posted February 15, 2010 Share Posted February 15, 2010 Slander for your information, i know Nicholas and if he was to read threads related to sanitizing scripts then he would notice great examples. Quote Link to comment Share on other sites More sharing options...
Jordan Palmer Posted February 15, 2010 Share Posted February 15, 2010 Hmm.. LOL @ "security" Remember Google is your best friend :) Quote Link to comment Share on other sites More sharing options...
Nicholas Posted February 15, 2010 Author Share Posted February 15, 2010 ive only been coding for just over 3 months lol, and im kinda a slow learner lol. also ive tried searching for security stuff on google, im not a good searcher lol. cant find any tips at all... i do happen to have a "essential PHP Security" book made by Chris Shiflett tho... im gonna try and learn them the book about security. Quote Link to comment Share on other sites More sharing options...
bluegman991 Posted February 17, 2010 Share Posted February 17, 2010 yeah that security thing will mess up ur gets and posts as i used it when i didnt know much about security and it will mess up something with ur greater/less than bars i cant remember what it does but an easier way to make new lines apear is to either preg replace \n with or nl2br(); Quote Link to comment Share on other sites More sharing options...
sniko Posted February 19, 2010 Share Posted February 19, 2010 echo nl2br($r['gangDESC']); May be wrong on the database feild but thats all you need Quote Link to comment 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.