PDA

View Full Version : problems with Inputtext


kusalacitta
11-17-2005, 03:53 AM
Hi All,

I have two problems with inputtext component.

1. Say that I want to post an article to inputtext, click a button, and save it contents to database. The contents of article can be put in inputtext as long as I want (I don't know the length of the article, but it has a long text).
But the problem is when I want to save it to my database. The contents cannot store to database (I use MySQL as db store and PHP). What's wrong about this??
If I reduce the length of text, for example If the article has 4-5 paragraphs (each of paragraph has 4-5 lines) then I reduce to be 3 paragraphs, the contents will be add to DB, but cannot for the one. I already set the maxlength attribute and set the property resizable to false of inputtext. But I still don't have a solution for this.

2. The inputtext run some methods inherited from LzText for example getSelectionPosition() and getSelectionSize() method, but the return value from this method must begin with running the setSelection method. So how if I want to get the length of selected text from inputtext? Is possible to do this? If not, how to handle the selection method and get the value from the selection text? Because in Chapter 17 - Text Views, I read that inputtext selection is handling by Laszlo and can return the length of the selected text.

Hope the help so much and thanks for the attention to this post :)

Regards,
Nina

javatis
11-17-2005, 04:49 AM
about 1)

if i understand u right ... u have a porblem to save text to databse IF it is to long?

--> if thats the problem, well bcould beklong to the method u sent the datas to the PHP file, i remember for one of the methods(post or get) there is a maximum of textlength depending to the method and the used browser becaus it send the data as attachment to the URL eg.: www.myDomain.com/myPHPfile.php?Title=this%20is%20my%20Title&Text=This%20would%20be%20my%20Article...

but it could also depend on the mysql database itselfs, mysql tables/fields has also a maxlengh denpending on the kind of tables/fields..

~~~~

or is also the shorter text not been saved?

--> then pls post the part of ur code that shws the way how u send the datas to php and pls show the php (cange the pw and username for ur db in the php code for ur own security pls)

~~~~

greetzs Sascha

kusalacitta
11-17-2005, 07:01 AM
if i understand u right ... u have a porblem to save text to databse IF it is to long? ==> Yes, it's my problem.

-------------------------------------

but it could also depend on the mysql database itselfs, mysql tables/fields has also a maxlengh denpending on the kind of tables/fields..
==> I set type of data from my field 'postcontent' to 'longtext' so the problem I think is not in the MySQL but is when I send the data to PHP using querystring.

Here is a piece of my source code to make it clear.

Btw about the question 2, do you have the solution?

Thanks a lot

javatis
11-17-2005, 10:05 AM
In HTML, one can specify two different submission methods for a form. The method is specified inside a FORM element, using the METHOD attribute. The difference between METHOD="GET" (the default) and METHOD="POST" is primarily defined in terms of form data encoding. The official recommendations say that "GET" should be used if and only if the form processing is idempotent, which typically means a pure query form. Generally it is advisable to do so. There are, however, problems related to long URLs and non-ASCII character repertoires which can make it necessary to use "POST" even for idempotent processing.

Source: http://www.cs.tut.fi/~jkorpela/forms/methods.html#fund

so i suggest u shoud try tu use POST instead of GET method which would mean-->


<dataset name="dsPosting" type="http" src="http://localhost:8383/laszloblog/posting.php" proxied="false" timeout="90000" querytype="POST"/>


in your lzx.

Greetz
Sascha

kusalacitta
11-19-2005, 08:53 AM
Hai Sascha,
Thanks for your pointer about GET and POST methods in HTML.
I tried your solution but POST method doesn't save the text into my database. Nothing value of parameter that send with this method (I use IEWatch to see the analysis of HTTP/HTTPS requests and the HTML source code).
In LZX, I write:
<method event="onclick"><![CDATA[
var d=canvas.datasets.dsPosting;
var p=new LzParam();
p.addValue("action","savepost",true);
p.addValue("PostTitle",titleinput.getText(),true);
p.addValue("PostContent",txtposting.getText(),true);
d.setQueryString(p);
d.setQueryType("POST");
d.doRequest();
]]>
</method>

Any suggests?

Thank you

bfagan
11-20-2005, 04:59 PM
just a thought... try setting the request type before you set the query string.

kusalacitta
11-21-2005, 07:14 AM
Hi bfagan,
I tried setting the query type before querystring, but the content (still) cannot save to database.
I get frustrated for handling the text :(

Any ideas?

Thanks so much for the help.

bfagan
11-21-2005, 07:20 AM
Assuming you're familiar with the Laszlo debug window, throw in a Debug.inspect(p); after you finish adding the values. This should let you see if your text is getting in there in the first place.

kusalacitta
11-21-2005, 07:59 AM
Hi bfagan,
I used IEWatch to see the analysis of my HTTP/HTTPS requests and I captured the proccess so you can see that nothing value send when using POST method. also in database, nothing data added to table article.

Do I change source code in PHP script from $_GET to $_POST too?

Thanks for the help

bfagan
11-21-2005, 08:02 AM
Certainly, your PHP should utilize the same method as your LZX code.

Did you using the Laszlo debug window?

kusalacitta
11-21-2005, 08:06 AM
here is the captured of request-response of test.lzx

bfagan
11-21-2005, 08:09 AM
Again...

I HIGHLY advise you to use the Laszlo debug window.

kusalacitta
11-21-2005, 08:19 AM
Ahhh...finally..the long text can be save to database! By changing the get request parameter method in PHP script to $_POST, it works fine! Thanks bfagan for your help and reply.

About question 2, do you have any suggestions?

Thanks again :)