PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I have a simple form that accepts data into a textfield and then enters it into a database. When it adds it to the db it converts quotes to â€. I have a function (mysql_prep) to check for magic_quotes or to apply mysqli_real_escape_string(). I tried to addslashes(). It still converts the quotes. Can anyone tell me how to stop this? Below is the code I have:
Ah, I've just been made aware of the fact that now the text outputs the actual html and instead of having paragraph breaks it shows "<br >." How do I still implement the html code but do away with the special characters? Is there a way to str_replace the <br> with a line break?
function br2nl($stringTobr2nl){
//returns a String where HTML line breaks have been converted to new lines.
//to Use: echo br2nl('my super <br/> broken string');
//or: $myFixedString=br2nl('my super <br/> broken string');
$brStrings[] = '<br>';
$brStrings[] = '<br/>';
$brStrings[] = '<br />';
$brStrings[] = '<br/ >';
$br2nl = str_replace($brStrings, "\r\n", $stringTobr2nl);
return $br2nl;
}
Okay, so the html breaks "<br />" are gone but it did not replace the line breaks. So, now we have one big paragraph - no line breaks. In the code you put \r\n in exchange for <br /> - is that the correct line break?
"\r\n" covers both Windows and Linux encoding for line breaks. Remember, though, that this only shows in the source code. If you want this to be viewable in HTML displayed in the browser, you need to put <pre> tags around it.
Still trying to get my head around this formatting. It seems everything I do makes another weird look to the page. It solves the last issue and then creates another.
Adding the <pre> tag added the line breaks but formatted as below: -- Weird line spacing.
The "circle of life" is filled with change; it is something everybody can count on experiencing.
At this moment we are experiencing seasonal changes in Virginia: Summer into Fall and Fall into Winter. Our lives consist of ongoing change.
We experience weather changes, economic change, physical changes, geographical change -- and, of course, political change.
Throw into the mix of these changes the fact that we change as we get older (and, hopefully, a little wiser), and it is small wonder that people feel confused, overwhelmed, and even a little lost.
Much like the flotsam and jetsam on the high seas, many are adrift on life's sea, and are searching for substance and a sense of permanency.
The truth is that THE ONLY CONSTANT IN AN EVER-CHANGING WORLD IS GOD.
Despite teachings to the contrary God is never angry at you. He loves you. He is Love, and Love "understands all things" -- even you and me.
God does not withhold blessing from us because yesterday that old, besetting weakness in our life won the battle of the day.
God never has a "blue Monday" or a "bad week".
He loves you and me with a love that does not waiver, never changes to any degree, nor does it stop because we stopped our obedient following of Him.