Jump to content

Remove New Line Codes


JustinK101

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/54705-remove-new-line-codes/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.