I have an issue that I'm sure there is a simple answer for. I have some data I'm inserting into a MySQL database. Here is a sample of data being inserted:
The problem I'm having is that when I insert this data in the DB, PHP is reading the \r and \n and similar type things and stripping it out of the text. Is there a way to prevent it from actually interpreting the newline character and just inserting it as text into the DB? I've searched around and messed with addslashes, stripslashes, etc, but I can't seem to figure it out.
For reference, here is the code block that I'm using for the insert:
for ($i=0; $i < count($rules); $i++) {
preg_match($sidregex, $rules[$i], $matches);
$sid = trim($matches[0], 'sid:;');
$qry_addrulestodb = "INSERT INTO sp_rules SET sid = '$sid', rule = '$rules[$i]'";
$qry_delbadrecs = "DELETE FROM sp_rules where sid=0";
if (!$queryresource = mysql_query($qry_addrulestodb, $dbconn)) {
trigger_error('Query Error ' . mysql_error() . ' SQL: ' . $sql);
}
if (!$queryresource = mysql_query($qry_delbadrecs, $dbconn)) {
trigger_error('Query Error ' . mysql_error() . ' SQL: ' . $sql);
}
I just wish they'd put back certain features I rely on daily, that worked in 10 and got taken out for no apparent reason or benefit in 11. Fortunately, I've found work arounds for most of them that restore them - but there is a sense that Microsoft is being actively malicious here and will block these workarounds eventually.
I don't mind adjusting to new systems - I started on an IBM 360 - but when it offers me literally zero new benefits and actually makes my life more difficult - what's in it for me other than avoiding Microsoft's constant passive-aggressive threats and unwillingness to listen to their customers?
I prefer MS Edge Browser, i used the Previous version of Edge when first released, and previously Internet Explorer from the very early days til it was replaced with Edge
Never got into Chrome myself, felt IE & Later Edge was just fine for my needs, as didn't really feel like installing another browser in other to surf the web.
** Though in 1998 i did try Netscape Navigator a little bit, but then i went back to Internet Explorer in about 1 month back then**
Question
Maverick88
Howdy Folks,
I have an issue that I'm sure there is a simple answer for. I have some data I'm inserting into a MySQL database. Here is a sample of data being inserted:
The problem I'm having is that when I insert this data in the DB, PHP is reading the \r and \n and similar type things and stripping it out of the text. Is there a way to prevent it from actually interpreting the newline character and just inserting it as text into the DB? I've searched around and messed with addslashes, stripslashes, etc, but I can't seem to figure it out.
For reference, here is the code block that I'm using for the insert:
Link to comment
https://www.neowin.net/forum/topic/991784-php-insert-into-mysql-removing-n-and-r/Share on other sites
11 answers to this question
Recommended Posts