{"id":2719,"date":"2020-04-11T15:40:35","date_gmt":"2020-04-11T14:40:35","guid":{"rendered":"https:\/\/ibex.tech\/cloud\/?p=2719"},"modified":"2022-02-17T07:13:48","modified_gmt":"2022-02-17T07:13:48","slug":"text-fields","status":"publish","type":"post","link":"https:\/\/ibex.tech\/cloud\/mysql\/columns-mysql\/text-fields","title":{"rendered":"Text fields"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Convert textarea ready to store in text column with line breaks etc<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>    $UserNotes = $_POST&#91;'UserNotes'];\n\n    $UserNotes = trim($UserNotes);\n    $UserNotes = stripslashes($UserNotes);\n    $UserNotes = htmlspecialchars($UserNotes, ENT_QUOTES);<\/code><\/pre>\n\n\n\n<p>\\n new line characters will still be stored as \\n (htmlspecialchars() doens\u2019t convert them to &lt;br&gt;)<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Convert \\n character to &lt;br&gt; when displaying<\/h4>\n\n\n\n<p>Not needed for a text area (it will respect \\n character) but nl2br() is needed when displaying as a general php string:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  $UserNotes = nl2br($UserNotes);<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Convert textarea ready to store in text column with line breaks etc \\n new line characters will still be stored as \\n (htmlspecialchars() doens\u2019t convert them to &lt;br&gt;) Convert \\n character to &lt;br&gt; when displaying Not needed for a text area (it will respect \\n character) but nl2br() is needed when displaying as a general [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[232],"tags":[],"class_list":["post-2719","post","type-post","status-publish","format-standard","hentry","category-columns-mysql"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/2719","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/comments?post=2719"}],"version-history":[{"count":6,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/2719\/revisions"}],"predecessor-version":[{"id":2732,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/2719\/revisions\/2732"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/media?parent=2719"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/categories?post=2719"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/tags?post=2719"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}