Jump to content

Recommended Posts

Posted

Hello,

can anybody explain what's the meaning of

"Parse error: syntax error, unexpected end of file in /home/user/public_html/file.php on line..."

thanks in advance

Posted

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.

Posted

Your very first if statement has no closing } :

if (isset($_POST['btn'])) {

 

You need to add one to close that if statement.

Posted

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

Posted

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.

Posted

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

Posted

It means your regular expression is incorrect. Can you post that line of code so I can see the expression in question?

Posted

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?

Posted

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
}
?>

Posted

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?

Posted

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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...