JustinK101 Posted June 8, 2007 Share Posted June 8, 2007 How do I remove newline codes? I dont simply mean \n, I mean an actual hidden newline character. The problem is my MySQL error outputting function: function fatal_error_alert($message, $sql_query) { if(empty($message) || empty($sql_query)) { return; } return "<script type=\"text/javascript\">alert(\"Fatal Error: " . $message . ".\n\nSQL Query: " . $sql_query . "\");</script>"; } Which I use like: result = mysql_query($sql) or die(fatal_error_alert(mysql_error(), $sql)); Currently newlines are breaking the javascript alert code. I am getting an unitialized string js error. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/54705-remove-new-line-codes/ Share on other sites More sharing options...
chigley Posted June 8, 2007 Share Posted June 8, 2007 Perhaps: $variable = str_replace("\n", "", $variable); Quote Link to comment https://forums.phpfreaks.com/topic/54705-remove-new-line-codes/#findComment-270769 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.