message/code shows up on my page and I cannot get rid of it...

No matter what I do, after a question is submitted on my site, these codes show up right above the “Your message has been sent” line…


Warning: preg_match() [function.preg-match]: Empty regular expression in /home/content/82/9307982/html/contact.php on line 77

Warning: preg_match() [function.preg-match]: Empty regular expression in /home/content/82/9307982/html/contact.php on line 77

And no matter what I edit in the php, it doesn’t go away…my brain now hurts and anything from anyone would be helpful at this point. Thank you in advance! Here is my line 77:

[php][/php]if (email_is_valid($youremail) && !preg_match("\r",$youremail) && !preg_match("\n",$youremail) && $yourname != “” && $yourmessage != “” && substr(md5($user_answer),5,10) === $answer) {

What are you trying to accomplish? just trying to make sure that there’s no new lines? with preg_match, you need to supply a valid pattern for it to match the input against. I’m no expert when it comes to that stuff, but there are lots of sites out there with decent tutorials for validation.

Also, preg_match uses a very complicated pattern system, it is not just checking for characters!

If you just want to check for characters in a string use strpos. It will return 0 if the string is found,
or the position in the string where it was found. So, it will work in effect as a boolean for your compare.
!strpos($youremail,"/r")

Or, just use str_replace to remove the /r and /n’s…

Good luck…

It looks like you may want to disable “display_errors” to off in your PHP ini file. The below may be displayed because it is set to YES.

[quote author=cmnessler link=topic=16489.msg54506#msg54506 date=1336077132]

Warning: preg_match() [function.preg-match]: Empty regular expression in /home/content/82/9307982/html/contact.php on line 77

Warning: preg_match() [function.preg-match]: Empty regular expression in /home/content/82/9307982/html/contact.php on line 77

Noob, we gave him the solution. Just to review… You can NOT do a preg_match without a valid regular expression. His is “\r” and another is “\n” These are not valid expressions. Here is a link to how to program the expressions which is NOT what he was trying to do. But, the solution was posted…

http://www.tipsntutorials.com/tutorials/PHP/50

As you will see, it is very complicated to figure out a valid regular expression.
Anyway Lots to learn in that subject!

[quote author=TheRoyalNoob link=topic=16489.msg54646#msg54646 date=1336189023]
It looks like you may want to disable “display_errors” to off in your PHP ini file. The below may be displayed because it is set to YES.

Disabling error messages won’t fix the problem. He has the right idea, he’s just going about it the wrong way.

Sponsor our Newsletter | Privacy Policy | Terms of Service