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 small problem bugging me which is not being fixed as quickly as i thought. I have a table which pulls titles out from the database, the problem being these titles can contain <br /> depending on if the user has hit return during the typing of the title. I am trying to display the title without <br />. I was reading at php.net about the strip_tags function so i tried to implement it here:
If you know that you never want the <br />, then maybe do this before inserting it into the database.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
I have yet to understand what "does not work" means because strip_tags most definitely does work.
Also, if someone typed a newline while in a textarea you would have received a newline character not a <br>. I'm thinking somewhere you have a nl2br that doesn't belong.
It looks like i have a nl2br, either way the user can press return while writing data. Then while that data is echo'd for the title of a row in a table it comes out as every return = <br />.
How do i prevent these <br /> interupting my titles.
synical21 wrote:I have fixed the problem now, Alan G solved it.
OK, what was it?
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Basically when the data was being inserted into the DB ensure /n was being used. For some reason <br> was being inserted into the DB for each new line. Then when i want the page to use line breaks i would use the nl2br function