I get input from a <textarea>. If my visitor adds carriage returns, the script changes them into <br>'s before reading the input into a text file. But when I read the text file back into the <textarea> (so that my visitor can make revisions to the original without having to type the whole thing over), it's one long line--no carriage returns. Anybody know how to feed out the text with carriage returns in a <textarea>? What do I change the <br>'s back into? n doesn't work. rn doesn't work. ?
I've written a small questionnaire in PHP. Several questions are to be completed in a text box. All data enters ok, but when I retrive the results with the following:
$query = 'SELECT * INTO OUTFILE "C:inetpubintranet esults'.$qnamed.''.$filenamedate.'.csv" fields terminated by "," lines terminated by " " FROM '.$qnamed.''
I encounter a problem. If the user completing the questionnaire has started a new line in the text box, then the file starts a new line every time a user did. Since I want to put this straight into excel (hence the .csv) it completly destroys the structure. I have tried to adding $question1 = trim($question1); when they are completing the questionnaire but it hasn't helped.
What I am trying to do is take a list that is typed into a text box and turn it into an unordered HTML list on output. I think I can use a foreach loop to setup the <LI> part of the list, but I am not sure how to have it scan the string for carriage returns and have it repeat the loop using those. I already have it setup to accept the data from a text box, but not sure how to proceed beyond that.
I have a WYSIWYG editor for a PHP form that I want to store the data in a MSSQL database. When I save the data, it seems it likes to add carriage returns when storing the data in the database. WHen I go in to view the data the second time around using the WYSIWYG the page encounters a problem (I have debugged and figured it is because of the carriage returns).
So I would like to have my submit.php page take the value of the POST['solution'] and remove any carriage returns there may be, before submitting the data into the SQL database.
I have found SQL carriage returns are the ascii characters char(13) and char(10), but it seems that I can not get rid of them.
I am using wordpress as a CMS and trying to allow user fields to be input to populate the info windows in a Google Map script. I am using this to select the id and pull in the content from a custom field.
It works fine unless there is any html in the custom-field which breaks the script. I looked at htmlspcialchar and htmlentities but rather than strip everything out I would like to have it escaped so it still works and the html is intact. Any suggestions? I am pretty new to PHP and would really appreciate any pointers.
After a while I am still unable to find a great solution for this. TheDeadMedic suggested I use esc_js
but that printed all of the actual html code instead of rendering it. Something else I tried was to use the trim function.. this is where I am at now where it works as long as no in the output. The $snip string, mapExcerpt field is where the returns are coming from:
<?php $post_id = 207; // Wordpress Post ID $my_post = get_post($post_id); $mapTitle = $my_post->post_title; $mapIMG = get_post_meta($post_id, 'mapImage', true);
Use nl2br()when displaying text that has carriage returns or line breaks in html, but when pulling from the DB and inserting the text into a textarea tag, the breaks and returns aren't being displayed.I know they're there, as I've not replaced them in any form.The only thing I worry about is that I have stripslashes() taking the escape character out, and it may be destroying the breaks.But it never displays an extra 'n' character at the end of what should be the paragraphs.Quote:This is some sample text and here comes a couple line breaks.This is some sample text.And here comes a couple line breaks.
I have a verrrrrrrry long base64 encoded string which is displayed in a textarea. The problem is that this string doesn't have any spaces or carriage returns so it gets displayed on one line with a ugly horizontal scroll bar.Can I add somehow carriage returns manually after base64_encode() and before output to the textarea, then remove these CR's after retrieving this string from the textarea (before decoding)?
I am having difficulty doing regular expressions when there is whitespace and carriage returns in between the text.For example in this case below, how can I get the regular expression to get "<div id="contentleft">"?
but I am sure I might have done something to screw up my testing.. I just need to replace 'magic happens' with something that works. Right now it just converts all of the newlines I am throwing at it to spaces.
Let's say I have a line of code in a MySQL table as following:
This is some text in a database table with a carriage return in the middle of it!
Now, if I grab that code and echo it, the text will show up in the browser with no line break, which is fine.† HOWEVER, if you look at the page source for that code, there is still the carriage return in the middle of the line.† My question is, how can I remove that carriage return from the text in the source code.
Which I need to create a regular expression for and extract the necessary data. I understand how to extract data from source files using regular expressions within PHP, using source text which has no "whitespace" or carriage returns.
I've got an html form, processed by php that writes to a csv text file that I would like opened in excel. Problem is that I have a multi-line text field that users are submitting hard returns in that excel looks at as new records. How can I have the php ignore the hard returns within the abstract multi-line text field? I know NOTHING about php for the record! It's the $abstract value that is causing the issue...
I want to translate measurements that Zend_Measure returns. Something like:
10 hours (en_US)
in my language
10 —á–į—Ā–į (bg - Bulgarian)
I found out that there is an archive with translations that i need - Zend/Locale/Data
There are a bunch of .xml files, many of them have translations for measurements.My idea is to use them to translate Zend_Measure measurement types. (After all these translations must be used for something...)
I have a form that is processed using PHP (post method) and there is a textarea people will enter text into. After processing, the text is displayed to the user.† However, if the user did a Carriage Return (i.e. hit Enter) when they originally entered the text, that text does NOT show on a new line when displayed later.
For example, if they type this into the text area...
"Hello there (they hit Enter here) How are you (they hit Enter here) Good I hope"
It will display like this, all on one line:
"Hello there How are you Good I hope"
In other words, it doesn't seem to remember that Enter was hit.
Is there some way to "preserve" the fact that someone hit the "Enter" key, so that when text is displayed later, it will show the text on a new line if the user in fact hit "Enter" when originally typing it.
I am probably not using the right terms in the right spots (i.e. newline, carriage return, enter, etc) but I think you get the picture
So must of us have a lot of content on our sites in one language or another. Since we are web professionals we spent all that time we could have been learning human languages - instead learning computer languages. So we need someway to translate our content.
Google provides a translation service (among others) and so given their massive empire I am confident that they do (or shortly will) have the best translation service. With that in mind, what is the best way to use it? We could just be lazy and use the little widget that they provide - but we would lose all the content and SEO juice because google would rewrite the links to point to "translate.googleusercontent.com?translate=...".
So my question is - how we can use this service while retaining the translated content on our site? One method would be to use the Google AJAX API to load the content inline when the wants it. But since it is powered by JS (like jQuery)- Search Engines won't benefit from this. Another method would be to use a server side language (like PHP) to scrap the content from the google translate page. But I'm not sure this is 100% legal. Finally, I was wondering about using mod_rewrite to fetch the page. But again, I don't think this would benefit our site.
All you would need to do is add a a couple links on your pages with the variables appended to the end of what ever URL is in the link and your set. //View file View Page in <a href="<?php print $uri_string; ?>-de">German</a>.....
Does anyone have an example of a PHP script/form where I can have two TEXTAREA on a form, and when I click on a cut/copy/paste button, it cut/copy/paste from one TEXTAREA to another. I know how to echo the contents of the TEXTAREA but I prefer to echo the contents to a TEXTAREA of the same form on the same page instead.
It is kinda like a FORM verification script but instead of loading the page using echoes, I want to be able to display the result of the TEXTAREA into another TEXTAREA on the same page. how the FORM should look like but I don't know how to code the PHP stuff.