this is probably an easy question but it is driving me mad. I have a form for users to add comments but if there is a ' symbol in the textarea then it will not upload.
I reckon it might have have something to do with the encoding. I am using phpmyadmin and the encoding for the textarea is utf8_gerenal_ci. But I can manually put this symbol into the database. It is only when it is uploaded through the form which has no character restrictions on the textarea.
There may be more symbols that cannot be uploaded. I don't want to have to stop users from using the ' symbol. Hopefully there is a simple answer even if it does make me look stupid. Thank you for your time.
You should do the changes on form part instead of database in this case.
See if this helps you -
How to pass apostrophies from text areas to MySQL using PHP
Try using addslashes() before sending form data to database.
eg. $str = $_POST['form_data];
$str = addslashes($str);
This function will escape all such characters which may cause problems while entering in db.
PLease read: http://php.net/manual/en/function.addslashes.php
Related
The thing is I have found how upload a document and after that downolad it. But I just want to download it. I want to do it using the UI designer but I dont know how to do it.
Thanks :)
I dont know which tool are you using to design your UI, anyway this is concerning functionality, not design. In that point, i need to know wich language do you want (or can) use. For example, in PHP, it's very simple, you can make something like:
(create php file) downloadpdf.php
1st: (if you want to generate pdf "on the fly":
<?php
function download($foo){
content headers (type, force-download, etc)
database select to get data or harcode it.
echo data
}
?>
and call this function with some id to select from database or something (ignore if you want to hardcode it)
Other option to download a file, if it's stored on server is making a link to this file (statically or dyamically). If you wanna take control to file downloads, check this post:
http://www.media-division.com/the-right-way-to-handle-file-downloads-in-php/
I don't mean that it can be done with UI designer tools, and it's not concerned if it's from a form or not.
Cheers!
You should create link and variable which type is javascript expression. On Variable value write
return "/bonita/portal/" + $data.context.mainDoc_ref.url;
On link URL write your variable and to text
Download: {{context.mainDoc_ref.fileName}}
Here you can find excellent example for this case
My website has the ability to be viewed in different languages. Is it possible to use sendKeys with a var that looks like this:
var arabic = "صباح الخير
I have tried using:
element(by.css(...)).sendKeys(arabic);
however question marks are the only characters sent to the text box.
Is this possible?
From Protractor point of view, if you see only ??? in input or whatever you are filling the extended chars in, it is probably a bug in that webpage, because generally sendKeys('باح الخير') works absolutely fine.
By the way, silly question, but have you tried pasting those extended chars to input directly, without protractor?
I just read this quite interesting post about security for CakePHP: Cakephp Security
It says that whenever a helper is used, CakePHP basically takes care security risks unless I turn of escape. I believe I only turn off escape when I want my links to be images, so nesting an image helper line inside a link helper line. For example:
echo $this->Html->link($this->Html->image('logo.png'), "/" , array('id'=>'logo', 'escape' => false));
Is that bad practise? Does that leave me vulnerable? Should I be doing it some other way?
Additionally, is it correct that whenever I output database data on dynamic pages, it needs to be enclosed in htmlspecialchars($myvariable)? I don't understand why I need to do that if I know that my database is clean from "bad stuff" and all of my forms for input into my database uses FormHelper.
In the example code shown you have all static values, no content coming from user so there's no risk.
Similarly for your content coming from database if for eg. all content is managed by site admin and no content from users is saved to database its reasonably safe to echo the content without escaping.
How can you get the value of a <textarea> and store it in a MySQL database table?
I'm using TinyMCE 3.3.9.3.
Seeing as no one has answered your question I thought I'd chip in. Have you ever managed to get any form data passed into a database before (I.E is it just accessing a textarea that's the problem), or is this a general question about how to put form data into databases?
One thing I would strongly recommend is moving away from WYSIWYG style editors if your seriously considering doing web development properly. From experience no matter how good they claim to be you'll always encounter cross browser problems and at some point you'll have to dig into the code and understand it.
Sorry this isn't a direct answer, but with a bit more info as to what you need to know I'm sure we can help... I warn you though, if you've not had much experience at this some of the answers could be a bit deep. I think maybe this is why you've not had any responses because the answer require could potentially be quite epic,lol.
Dan
The tinymce editor id equals the textarea id.
Assuming that editor is your tinymce editor instance you may use the following to get the textareaa content (which is then equal to the editor content).
editor.triggerSave(); // update the textarea
var textarea_element = document.getElementById(editor.id); // get the updated textarea
var content = textarea_element.innerHTML; // this is the content
// now you need to call a script to save the content (i suggest you use ajax)
...
Newbie question here.
I have a web form with a text area and naturally users will enter newline characters also. I am storing this form to a table in the DB. I also have to create a report from this. So I dump the table to text and am trying to parse it. The delimiters for me between multiple records is a new line character. But the new line character in the text area is throwing my script off.
I am sure someone must have run into this before. Can you suggest me ideas as to how to deal with this?
I tried having the text from the text area in double quotes but that will complicate my parsing logic. I was wondering if there is an easier way to deal with this.
I think the simple answer is some form of escaping.
You could do some find/replace in the SQL, such as REPLACE(thetext, '\n', '\\n'), or if the newlines are not important, you could do REPLACE(thetext, '\n', ' ')
Recently ran into the same issue. Your best best is to replace the newline characters during the data dump (or before the data gets to your database) with something else. I opted for something like // or <br> so that I can recover the new lines later.
I was trying to build one forum. The problem was when some user enters HTML. It would get translated when you display his post. And I was not able to move to next line when displaying his post. This might help you. I'm using PHP by the way.
$pattern = array('/</','/>/','/\n/');
$replace = array('<','>','<br>');
$post = preg_replace($pattern,$replace,$post);