Jump to content

Need Explanation In Php Errors


Recommended Posts

The code is broken. That error usually means you're missing a closing symbol somewhere. likely a missing } or ) symbol. Make sure you have a matching ) or } for every ( or { in your code. A missing semicolon on the last line can also cause it.

Link to comment
Share on other sites

Hi,

why i cannot use header fuction? It's always show an error? Am i did wrong?

This is the error,

Warning: Cannot modify header information - headers already sent by (output started at /home1/mhr2/public_html/system/fnc.php:52) in /home1/mhr2/public_html/profile.php on line 3

please help me

Link to comment
Share on other sites

Headers must be sent before any output (text, HTML, even an error) is sent. Once you send some type of content, you cannot use the header function.

 

Whatever is on line 52 of fnc.php sent some form of output. I'd expect to find either an echo statement, part of the page body or an include that points such, or a broken line of code that's producing an error. You need to make sure your header function is called before that line of code runs, otherwise normal HTTP headers are automatically sent along with the output.

Link to comment
Share on other sites

Hi, what about this sir?

Warning: preg_match() [ function.preg-match]: Compilation failed: range out of order in character class at offset 13 in /home1/mhr2/public_html/system/signup.php on line 26

i just want to validating input form.

Help me please

Link to comment
Share on other sites

Ok.. I have knew what the cause of. The cause is that after i am extracting my file, it's changed to other expression. I dont know why.

Now the issue is that i want to restrict users to inputing characters such as [(#...etc. But i always failed.. :(

can you help me please, to restrict the users to do it and just _ and - that allowed?

Link to comment
Share on other sites

If you want to only allow a single - or _ symbol as the input, use an IF statement instead. There is no "range" for symbols in a regexp, and you'll probably have to escape a bunch of them with a \ since some are modifiers in regexps.

 

Regexps really are most useful when doing complex searches/pattern matching or when you need to accept large ranges like a-z or 0-9, as opposed to a few allowed characters.

 

An IF like this would be easier if a single - or _ should be the only thing allowed:

<?php
if ($input = "_" || $input = "-") {
//Do something
} else {
//Error message
}
?>

Link to comment
Share on other sites

No. I mean symbols is only - and _ that allowed. And support numeric, letters (uppercase lowercase) also.

I am it for validating nick name.

Here is the line

if (!empty($nick) && preg_match("/^([a-zA-Z0-9\ _\-] )*$/", $nick))

but i thing it is correct, but still not work.

What is wrong?

Link to comment
Share on other sites

The start of line and end of line are not required. Also, it's easier to check for the presence of bad characters as opposed to making sure they're all good.

 

<?php
$nick = "TEST33%";
if (!empty($nick) && preg_match("/([^a-zA-Z\d_-])/", $nick))
{
echo "Invalid characters";
} else {
echo " It's good. ";
}
/* Produces output:

Invalid Characters

*/

Change the first line to a valid name and it will produce "It's good" instead.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...