Jump to content

help/advice with group permissions cms and file-manager.


boo_lolly

Recommended Posts

for right now, i've pretty much got the concept of what i want to do. there are a few loose ends but i will iron those out a little later in this thread... but for now... i cannot seem to figure out why i'm getting this error:

Parse error: parse error on line 32

 

i've looked everywhere and i can't seem to figure it out...

 

here's my quick rough-drafted code so far:

<?php
        /*createaccount.php*/
        if(isset($_POST)){
                /*run sanitize function for each $_POST var and email validation here*/

                $sql = "SELECT * FROM users WHERE username = '{$_POST['username']}'";
                $query = mysql_query($sql) OR die(mysql_error());

                if(mysql_num_rows($query) > 0){
                        echo "<span style=\"color:red\">
                                User name {$_POST['username']} already exists. Please try again with a different username.
                                </span>\n";
                }else{
                        $sql = "INSERT INTO
                                users(
                                        username,
                                        first_name,
                                        last_name,
                                        email,
                                        user_group,
                                        date_created
                                        )
                                VALUES(
                                        '". $_POST['username'] ."',
                                        '". $_POST['first_name'] ."',
                                        '". $_POST['last_name'] ."',
                                        '". $_POST['email'] ."',
                                        '". $_POST['user_group'] ."',
                                        '". time() ."'

                                        }
                                ";

                        mysql_query($sql) OR die(mysql_error());
                        echo "<span style=\"color:green\">
                                {$_POST['username']}'s account was created successfully.
                                </span>\n";
                }
        }
/*THIS IS LINE 32*/
        echo "
                Create an account:<br />
                <form action=\"\" method=\"post\">
                Username: <input type=\"text\" name=\"user_name\" value=\"". ((if(isset($_POST['username']) ? ("{$_POST['username']}") : ("")) ."\"><br />
                First Name: <input type=\"text\" name=\"user_name\" value=\"". ((if(isset($_POST['first_name']) ? ("{$_POST['first_name']}") : ("")) ."\"><br
/>
                Last Name: <input type=\"text\" name=\"user_name\" value=\"". ((if(isset($_POST['last_name']) ? ("{$_POST['last_name']}") : ("")) ."\"><br />
                Email: <input type=\"text\" name=\"user_name\" value=\"". ((if(isset($_POST['email']) ? ("{$_POST['email']}") : ("")) ."\"><br />
                User Group:
                <select name=\"user_group\">
                <option value=\"1\">Admin</option>
                <option value=\"2\">Just Below Admin</option>
                <option value=\"3\">Regular User</option>
                <option value=\"4\">Reader</option>
                <option value=\"5\">Guest</option>
                </select>

                ";
?>

 

anybody see something i don't?

If I had to guess it is because of the inner if statements lol.

 

        echo "
                Create an account:<br />
                <form action=\"\" method=\"post\">
                Username: <input type=\"text\" name=\"user_name\" value=\"". isset($_POST['username']) ? ("{$_POST['username']}") : ("") ."\"><br />
                First Name: <input type=\"text\" name=\"user_name\" value=\"". isset($_POST['first_name']) ? ("{$_POST['first_name']}") : ("") ."\"><br
/>
                Last Name: <input type=\"text\" name=\"user_name\" value=\"". isset($_POST['last_name']) ? ("{$_POST['last_name']}") : ("") ."\"><br />
                Email: <input type=\"text\" name=\"user_name\" value=\"". isset($_POST['email']) ? ("{$_POST['email']}") : ("") ."\"><br />
                User Group:
                <select name=\"user_group\">
                <option value=\"1\">Admin</option>
                <option value=\"1\">Just Below Admin</option>
                <option value=\"1\">Regular User</option>
                <option value=\"1\">Reader</option>
                <option value=\"1\">Guest</option>
                </select>

                ";

 

 

It looks like you have too many open parenthesis before your if statements inside the echo.

 

if you're talking about this:

mysql_query($sql) OR die(mysql_error());

 

that's not it. i have the right amount of parenthesis there.

 

If I had to guess it is because of the inner if statements lol.

 

what do you mean 'inner if statement'? do you simply mean nested if statements?

link=topic=136316.msg575860#msg575860 date=1176755942]

you forgot a ')' here

if(mysql_num_rows($query) > 0){

 

it's there. don't you see it?

 

 

I was talking about this...

 

((if(isset($_POST['username']) ? ("{$_POST['username']}") : (""))

 

6 open... 4 close.

 

good eye bro, except that would have been the next error thrown after i figured this one out =P

 

 

Everything is right, the error is in the last echo statement within the inner-ifs. Trust me.

 

You can choose to try the solution I provided above and see what happens???

 

sorry, i didn't realize you posted something for me to try. but what exactly is the problem with my echo func? how does yours differ from mine?

If you cannot figure out the difference, than you need to look very hard. Mine has correct parans etc. That and I have seen issues before with the if statement being concatenated inside of echo and print. But hey if it works with that Charlie said, all the better. Just very confusing with all those parans to confuse you with.

ladies and gentlemen, i apologize but i have mislead you all. the error line i commented in my code was actually line 39, not line 32....

 

THIS is line 32, and THIS is where the problem resides:

<?php
        /*createaccount.php*/
        if(isset($_POST)){
                /*run sanitize function for each $_POST var and email validation here*/

                $sql = "SELECT * FROM users WHERE username = '{$_POST['username']}'";
                $query = mysql_query($sql) OR die(mysql_error());

                if(mysql_num_rows($query) > 0){
                        echo "<span style=\"color:red\">
                                User name {$_POST['username']} already exists. Please try again with a different username.
                                </span>\n";
                }else{
                        $sql = "INSERT INTO
                                users(
                                        username,
                                        first_name,
                                        last_name,
                                        email,
                                        user_group,
                                        date_created
                                        )
                                VALUES(
                                        '". $_POST['username'] ."',
                                        '". $_POST['first_name'] ."',
                                        '". $_POST['last_name'] ."',
                                        '". $_POST['email'] ."',
                                        '". $_POST['user_group'] ."',
                                        '". time() ."'
                                        }
                                ";
/*THIS IS THE REAL LINE 32*/
                        mysql_query($sql) OR die(mysql_error());
                        echo "<span style=\"color:green\">
                                {$_POST['username']}'s account was created successfully.
                                </span>\n";
                }
        }

        echo "
                Create an account:<br />
                <form action=\"\" method=\"post\">
                Username: <input type=\"text\" name=\"user_name\" value=\"". (((isset($_POST['username'])) ? ("{$_POST['username']}") : ("")) ."\"><br />
                First Name: <input type=\"text\" name=\"user_name\" value=\"". (((isset($_POST['first_name'])) ? ("{$_POST['first_name']}") : ("")) ."\"><br />
                Last Name: <input type=\"text\" name=\"user_name\" value=\"". (((isset($_POST['last_name'])) ? ("{$_POST['last_name']}") : ("")) ."\"><br />
                Email: <input type=\"text\" name=\"user_name\" value=\"". (((isset($_POST['email'])) ? ("{$_POST['email']}") : ("")) ."\"><br />
                User Group:
                <select name=\"user_group\">
                <option value=\"1\">Admin</option>
                <option value=\"2\">Just Below Admin</option>
                <option value=\"3\">Regular User</option>
                <option value=\"4\">Reader</option>
                <option value=\"5\">Guest</option>
                </select>

                ";
?>

 

again, i apologize.

 

 

If you cannot figure out the difference, than you need to look very hard. Mine has correct parans etc. That and I have seen issues before with the if statement being concatenated inside of echo and print. But hey if it works with that Charlie said, all the better. Just very confusing with all those parans to confuse you with.

 

sorry bro... i have no idea what the hell i was thinking... i took out the 'if' inside my 'if' hahaha. again, i apologize. however, that did not fix the issue.

                                        '". $_POST['last_name'] ."',
                                        '". $_POST['email'] ."',
                                        '". $_POST['user_group'] ."',
                                        '". time() ."'
                                        }

SHOULD BE

                                        '". $_POST['last_name'] ."',
                                        '". $_POST['email'] ."',
                                        '". $_POST['user_group'] ."',
                                        '". time() ."'
                                        )

 

} should be )

Parse error: parse error in createaccount.php on line 32

 

i've added a few blank lines to my sql string, and it still says error on line 32... i know that should help me diagnose the issue, but i have no idea what it means when i add blank lines to my sql string, and it still brings the same error on the same line, even tho now my sql string is bleeding past line 32.

alright guys, i figured it out... i was writing to a file in my vim editor, and saving it as another. but i didn't change the filename in my browser...

 

so now that's taken care of, i'llb e posting here in this thread the next time i hit a road bump with this small project. thanks for all your time guys! you'll be hearing from me soon.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.