473,395 Members | 1,532 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Warning: ereg(): REG_BADBR

why i m getting error here???

Warning: ereg(): REG_BADBR
code:
if(!ereg("^(.){15,400}$",$string)) {
$errormsg[1] = "- Must be more then 15 Characters & less then 400
Characters";
}
Want to Achive:
$string is a textarea, i want the user to input atleast 15 characters
and shldnt exceed more then 400 characters!

thnx

Apr 28 '06 #1
6 4080
<mi******@gmail.com> wrote in message
news:11**********************@j73g2000cwa.googlegr oups.com...
why i m getting error here???

Warning: ereg(): REG_BADBR
code:
if(!ereg("^(.){15,400}$",$string)) {
$errormsg[1] = "- Must be more then 15 Characters & less then 400
Characters";
}
Want to Achive:
$string is a textarea, i want the user to input atleast 15 characters
and shldnt exceed more then 400 characters!

Don't know, but why would you need to use a regexp for so trivial case?
Remember the KISS rule: Keep it simple, stupid.

if( ($len = strlen($string)) < 15 || $len > 400) {
$errormsg[1] = "- Must be more then 15 Characters & less then 400
Characters";
}

--
"ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" -lpk
sp**@outolempi.net | Gedoon-S @ IRCnet | rot13(xv***@bhgbyrzcv.arg)
Apr 28 '06 #2
<mi******@gmail.com> wrote in message
news:11**********************@j73g2000cwa.googlegr oups.com...
why i m getting error here???

Warning: ereg(): REG_BADBR
code:
if(!ereg("^(.){15,400}$",$string)) {


^
It just occured to me, the dollar sign inside double quotes " " should
propably be escaped, otherwise php might confuse it for a variable marker,
but the variable is missing. for example: "$cat" replaces $cat with the
value of the variable. here you have "$". Either escape it or use single
quotes. "^(.){15,400}\$" or '^(.){15,400}$'. But as I already said, using
strlen is much more simple way. If you have to use the regular expression
(can't think of a reason why though), you can fix it with that.

--
"ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" -lpk
sp**@outolempi.net | Gedoon-S @ IRCnet | rot13(xv***@bhgbyrzcv.arg)
Apr 28 '06 #3
mi******@gmail.com wrote:
why i m getting error here???

Warning: ereg(): REG_BADBR
code:
if(!ereg("^(.){15,400}$",$string)) {
$errormsg[1] = "- Must be more then 15 Characters & less then 400
Characters";
}
Want to Achive:
$string is a textarea, i want the user to input atleast 15 characters
and shldnt exceed more then 400 characters!

thnx

Although I am all pro-serverside coding, I'd rather implement these
simple input type checks on the client side, using Javascript. Much more
user-friendly than filling out forms and after each submit be told it's
wrong.

Besides, ereg is slow, compared to strlen, as Kimmo already explained
how to use.

Sh.

--
Backbone Scoliosis
Apr 28 '06 #4
wow that kool!!!

thnx alot!
Kimmo Laine wrote:
<mi******@gmail.com> wrote in message
news:11**********************@j73g2000cwa.googlegr oups.com...
why i m getting error here???

Warning: ereg(): REG_BADBR
code:
if(!ereg("^(.){15,400}$",$string)) {
$errormsg[1] = "- Must be more then 15 Characters & less then 400
Characters";
}
Want to Achive:
$string is a textarea, i want the user to input atleast 15 characters
and shldnt exceed more then 400 characters!

Don't know, but why would you need to use a regexp for so trivial case?
Remember the KISS rule: Keep it simple, stupid.

if( ($len = strlen($string)) < 15 || $len > 400) {
$errormsg[1] = "- Must be more then 15 Characters & less then 400
Characters";
}

--
"ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" -lpk
sp**@outolempi.net | Gedoon-S @ IRCnet | rot13(xv***@bhgbyrzcv.arg)


Apr 28 '06 #5
>Although I am all pro-serverside coding, I'd rather implement these
simple input type checks on the client side, using Javascript.
I hope you mean you'd rather implement these checks ALSO on the client
side.
Much more
user-friendly than filling out forms and after each submit be told it's
wrong.


User-friendly should not substitute for security and data integrity.
You still need the checks on the server side. Nothing wrong with
doing it on the client also.

Gordon L. Burditt
Apr 28 '06 #6
Gordon Burditt wrote:
Although I am all pro-serverside coding, I'd rather implement these
simple input type checks on the client side, using Javascript.

I hope you mean you'd rather implement these checks ALSO on the client
side.

Much more
user-friendly than filling out forms and after each submit be told it's
wrong.

User-friendly should not substitute for security and data integrity.
You still need the checks on the server side. Nothing wrong with
doing it on the client also.

Gordon L. Burditt


Correct on both accounts. I never assume anything to be safe sent by a
client. In fact I think I can be categorized under the 'paranoid'
section wrt security issues. Professional deformity I guess...

Thx
Sh.

Sh.

--
Love is what you've been through with somebody.
-- James Thurber
Apr 29 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Stefan Gangefors | last post by:
I'm trying to figure out what I'm doing wrong when using ereg(). This is my regexp: ereg("^]$", "]"); and that does'n work, but this does: ereg("^$", "[");
9
by: Fiore Alessandro | last post by:
Hi all I've installed Apache 2.0.48 and PHP 4.3.4 on a workstation running Linux, RedHat 9.0. Let's consider the following piece of code: $patt = "{3}/{6}"; if...
3
by: Martin Lucas-Smith | last post by:
Is there some way of using ereg to detect when certain filename extensions are supplied and to return false if so, WITHOUT using the ! operator before ereg () ? I have an API that allows as an...
2
by: pomho | last post by:
Hi all, Even having read the PHP Manual, I can't understand the difference between the ereg function and the preg_match... Could anyone help ? thx in advance, --
3
by: Rafal Zak | last post by:
I have a little problem with ereg (eregi) in PHP - in some cases it behaves differently than I expect and I don`t know if my expectations are strange or there is any "syntax subtlety" I have...
3
by: Dynamo | last post by:
Hi, Thanks to all who replied to original posting.As a direct result of now gaining a better understanding of regular expressions, instead of trying to use other peoples scripts I am now trying to...
3
by: news | last post by:
I'm trying to make sure a form has only one or two digits in either of two fields. I looked at php.net and http://www.regular-expressions.info/reference.html and this is what I put together, but...
18
by: yawnmoth | last post by:
Say I have the following script: <? $string = 'test'; if (eregi("^+$",$string)) { echo 'matches!'; } else {
4
by: gsaray101 | last post by:
I keep getting PHP Warning: Unexpected character in input: '\' (ASCII=92)) this error on windows platform. this script works fine on Linux. Can anybody help? This script is supposed to return the...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.