Hi everybody :-)
I'm working with latest chronoform and joomla 1.5.7...
I've built a form witch use javascript to limit textarea to 4000 chars.
Everything's okay but I need a server validation for people trying to deactivate javascript or simply use a browser that don't support it fully.
The problem is :
If i submit this form with a fully loaded textarea of 4000 chars then the server tell me this is too much !
I've tried a lot : strlen() mb_strlen($string,'UTF-8'), stripslashes before counting chars...
everytime my variable is over 4000...
So I understand it has to do with what append to the data before the validation script run...
Somebody has an idea about this ?
Thanks very much if you can help...
I'm working with latest chronoform and joomla 1.5.7...
I've built a form witch use javascript to limit textarea to 4000 chars.
Everything's okay but I need a server validation for people trying to deactivate javascript or simply use a browser that don't support it fully.
The problem is :
If i submit this form with a fully loaded textarea of 4000 chars then the server tell me this is too much !
I've tried a lot : strlen() mb_strlen($string,'UTF-8'), stripslashes before counting chars...
everytime my variable is over 4000...
So I understand it has to do with what append to the data before the validation script run...
Somebody has an idea about this ?
Thanks very much if you can help...
Hi gilloux7,
did you try the server validation in Chronoforms ? you can count the posted string from this textarea and display some error ?
regards
Max
did you try the server validation in Chronoforms ? you can count the posted string from this textarea and display some error ?
regards
Max
Hi Max,
This is exactly what I do !
I put my validation code in the right tab but mb_strlen() php function returns more chars that's expected...
I suppose chronoforms add something in the textarea before the validation script...?
This is exactly what I do !
I put my validation code in the right tab but mb_strlen() php function returns more chars that's expected...
I suppose chronoforms add something in the textarea before the validation script...?
Hi gilloux,
Is the problem that mb_strlen counts multi-byte characters as '1'? The Notes in the php manual suggest using mb_strlen($string, '8bit'); to count the byte length.
Bob
Is the problem that mb_strlen counts multi-byte characters as '1'? The Notes in the php manual suggest using mb_strlen($string, '8bit'); to count the byte length.
Bob
Hi Bob,
The problem is that my javascript counts correctly the numbers of chars in the textarea but php on the validation side, counts more ! So I think mb_strlen count enough chars... something adds a few things in the texarea before the validation script I guess...
Thanks for your answer guys ! I feel less alone with this strange problem !
The problem is that my javascript counts correctly the numbers of chars in the textarea but php on the validation side, counts more ! So I think mb_strlen count enough chars... something adds a few things in the texarea before the validation script I guess...
Thanks for your answer guys ! I feel less alone with this strange problem !
Hi gilloux,
I don't think that anything is added - at least not deliberately :-(
Bob
I don't think that anything is added - at least not deliberately :-(
Bob
Hi gilloux,
I don't think that anything is added - at least not deliberately :-(
Bob
thanks bob,
not deliberately i think so...
And now you know what ?
This bite of code return me a T variable error..
Do you find it ?
<?php
$introlimit=501;
$fullimit=4000;
$replace="";
$full=$_POST['fulltext'];
$full=str_replace(Chr(13), $replace, $full);
$full=str_replace(Chr(10), $replace, $full);
$full=stripslashes($full);
if(!trim($_POST['title']))
return "Désolé mais le texte a besoin d'un Titre !";
if($_POST['catid']=='none')
return "Il faut sélectionner une catégorie !";
if(!trim($_POST['introtext']))
return "Désolé mais le texte a besoin d'un résumé !";
if(!trim($_POST['fulltext']))
return "Il faut quand même écrire quelque chose !";
$much=mb_strlen($full,'UTF-8');
echo "Variable nb chars fulltext : ".$much."<br />";
echo "var full : ".mb_detect_encoding($full)."<br />";
echo "var much : ".mb_detect_encoding($much)."<br />";
if($much>$fullimit)
return "Trop de caractères dans le texte ! - Activez Javascript svp.";
?>
Hi gilloux7,
I don't see any errors in there . . . do you get any line numbers in the error message?
Bob
I don't see any errors in there . . . do you get any line numbers in the error message?
Bob
you may try to test the mb_strlen and strlen with some defined string first and see how they behave ? its hard to test with the real data directly if you got a problem like this.
Regards
Max
Regards
Max
The error is :
And i've already tried to test the mb_strlen.strlen function with simple variable witch is ok...
It's about 5 days that i'm stuck with this problem...
Ah yes I've also replced the mb_strlen with a "manual" function like this :
The problem is the same !
So i thought something is added somewhere by chronoform...
Parse error: syntax error, unexpected T_VARIABLE in /Users/plume/Sites/ruedesauteurs/components/com_chronocontact/chronocontact.php(190) : eval()'d code on line 6And i've already tried to test the mb_strlen.strlen function with simple variable witch is ok...
It's about 5 days that i'm stuck with this problem...
Ah yes I've also replced the mb_strlen with a "manual" function like this :
function new_mb_strlen( $str, $enc="" ) {
$counts = count_chars( $str );
$total = 0;
// Count ASCII bytes
for( $i = 0; $i < 0x80; $i++ ) {
$total += $counts[$i];
}
// Count multibyte sequence heads
for( $i = 0xc0; $i < 0xff; $i++ ) {
$total += $counts[$i];
}
return $total;
}The problem is the same !
So i thought something is added somewhere by chronoform...
Hi gilloux,
I suspect that chr() is now case-sensitive and that Chr() is giving you the error.
Bob
I suspect that chr() is now case-sensitive and that Chr() is giving you the error.
Bob
Thanks bob but it's not... still got the error !
When I comment the str_replace() lines the error disapear (whatever the syntax), Developpers be aware of that !
I think I've found a new bug..
Does anybody master the ereg function to replace.. str_replace ?!
I just want to remove the \n\r from the textarea before the counting...
thanks
When I comment the str_replace() lines the error disapear (whatever the syntax), Developpers be aware of that !
I think I've found a new bug..
Does anybody master the ereg function to replace.. str_replace ?!
I just want to remove the \n\r from the textarea before the counting...
thanks
Hi gilloux7,
why do you want to replace str_replace with ereg ?
try to use the function nl2br then replace the <br> with str_replace ?I'm not sure this will work, but let me know!
Regards
Max
why do you want to replace str_replace with ereg ?
try to use the function nl2br then replace the <br> with str_replace ?I'm not sure this will work, but let me know!
Regards
Max
Ok max
I probably have some difficulty to make me understood cause english is not a usual language for me..
whatever the syntax with str_replace I have a syntax error so I thought chronoform have some difficulty with this function...
I definitly have a syntax error only with the str_replace used on the validation side... And I'm sure of the syntax though, I tried on differents server too...
So I want to try with an ereg function to confirm my diagnosis...
I probably have some difficulty to make me understood cause english is not a usual language for me..
whatever the syntax with str_replace I have a syntax error so I thought chronoform have some difficulty with this function...
I definitly have a syntax error only with the str_replace used on the validation side... And I'm sure of the syntax though, I tried on differents server too...
So I want to try with an ereg function to confirm my diagnosis...
Hi gilloux7,
why do you want to replace str_replace with ereg ?
try to use the function nl2br then replace the <br> with str_replace ?I'm not sure this will work, but let me know!
Regards
Max
I did like this :
$full=nl2br($full);
$full=stripslashes($full);
$full=strip_tags($full);No errors but still counting too much chars...
try to echo the $full in a textarea after submit and see what does it have exactly ?
regards
Max
regards
Max
Hi Max
Do you mean this ?
the result is that the code is not parsed... I see the php code in the resulting page !
Do you mean this ?
echo '<textearea>'.$full.'</textarea>';the result is that the code is not parsed... I see the php code in the resulting page !
If I type
Devs, don't you think there's some bugs in the validation side of chronoforms ?
</textarea> this portion gets deleted after saving the form...Devs, don't you think there's some bugs in the validation side of chronoforms ?
Hi gilloux,
I have no idea what the problem is any more, neither of your last two posts made any sense to me.
Please post some real examples saying exactly what is happening and we may be able to help you.
Bob
I have no idea what the problem is any more, neither of your last two posts made any sense to me.
Please post some real examples saying exactly what is happening and we may be able to help you.
Bob
Well thanks bob !
I understand, too long time between posts...
I think i'm about to find a solution for my problem... not sure I'll tell you.
Thanks again !
I understand, too long time between posts...
I think i'm about to find a solution for my problem... not sure I'll tell you.
Thanks again !
Hi Max
Do you mean this ?
echo '<textearea>'.$full.'</textarea>';the result is that the code is not parsed... I see the php code in the resulting page !
do you put it inside PHP tags ?
This topic is locked and no more replies can be posted.
