boo_lolly Posted April 16, 2007 Share Posted April 16, 2007 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? Link to comment https://forums.phpfreaks.com/topic/47296-helpadvice-with-group-permissions-cms-and-file-manager/ Share on other sites More sharing options...
soycharliente Posted April 16, 2007 Share Posted April 16, 2007 It looks like you have too many open parenthesis before your if statements inside the echo. Link to comment https://forums.phpfreaks.com/topic/47296-helpadvice-with-group-permissions-cms-and-file-manager/#findComment-230701 Share on other sites More sharing options...
per1os Posted April 16, 2007 Share Posted April 16, 2007 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> "; Link to comment https://forums.phpfreaks.com/topic/47296-helpadvice-with-group-permissions-cms-and-file-manager/#findComment-230703 Share on other sites More sharing options...
boo_lolly Posted April 16, 2007 Author Share Posted April 16, 2007 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 to comment https://forums.phpfreaks.com/topic/47296-helpadvice-with-group-permissions-cms-and-file-manager/#findComment-230705 Share on other sites More sharing options...
clown[NOR] Posted April 16, 2007 Share Posted April 16, 2007 you forgot a ')' here if(mysql_num_rows($query) > 0){ EDIT: never mind... i just found out i'm blind Link to comment https://forums.phpfreaks.com/topic/47296-helpadvice-with-group-permissions-cms-and-file-manager/#findComment-230706 Share on other sites More sharing options...
per1os Posted April 16, 2007 Share Posted April 16, 2007 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??? Link to comment https://forums.phpfreaks.com/topic/47296-helpadvice-with-group-permissions-cms-and-file-manager/#findComment-230708 Share on other sites More sharing options...
soycharliente Posted April 16, 2007 Share Posted April 16, 2007 I was talking about this... ((if(isset($_POST['username']) ? ("{$_POST['username']}") : ("")) 6 open... 4 close. Link to comment https://forums.phpfreaks.com/topic/47296-helpadvice-with-group-permissions-cms-and-file-manager/#findComment-230710 Share on other sites More sharing options...
boo_lolly Posted April 16, 2007 Author Share Posted April 16, 2007 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? Link to comment https://forums.phpfreaks.com/topic/47296-helpadvice-with-group-permissions-cms-and-file-manager/#findComment-230711 Share on other sites More sharing options...
clown[NOR] Posted April 16, 2007 Share Posted April 16, 2007 yeah i just saw it... and edited my post Link to comment https://forums.phpfreaks.com/topic/47296-helpadvice-with-group-permissions-cms-and-file-manager/#findComment-230714 Share on other sites More sharing options...
per1os Posted April 16, 2007 Share Posted April 16, 2007 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. Link to comment https://forums.phpfreaks.com/topic/47296-helpadvice-with-group-permissions-cms-and-file-manager/#findComment-230715 Share on other sites More sharing options...
boo_lolly Posted April 16, 2007 Author Share Posted April 16, 2007 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. Link to comment https://forums.phpfreaks.com/topic/47296-helpadvice-with-group-permissions-cms-and-file-manager/#findComment-230718 Share on other sites More sharing options...
per1os Posted April 16, 2007 Share Posted April 16, 2007 '". $_POST['last_name'] ."', '". $_POST['email'] ."', '". $_POST['user_group'] ."', '". time() ."' } SHOULD BE '". $_POST['last_name'] ."', '". $_POST['email'] ."', '". $_POST['user_group'] ."', '". time() ."' ) } should be ) Link to comment https://forums.phpfreaks.com/topic/47296-helpadvice-with-group-permissions-cms-and-file-manager/#findComment-230724 Share on other sites More sharing options...
boo_lolly Posted April 16, 2007 Author Share Posted April 16, 2007 } should be ) thanks frost. good eye, but no dice =\. still the same error... WTF is going on!? Link to comment https://forums.phpfreaks.com/topic/47296-helpadvice-with-group-permissions-cms-and-file-manager/#findComment-230730 Share on other sites More sharing options...
per1os Posted April 16, 2007 Share Posted April 16, 2007 What is the exact error? Link to comment https://forums.phpfreaks.com/topic/47296-helpadvice-with-group-permissions-cms-and-file-manager/#findComment-230734 Share on other sites More sharing options...
boo_lolly Posted April 16, 2007 Author Share Posted April 16, 2007 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. Link to comment https://forums.phpfreaks.com/topic/47296-helpadvice-with-group-permissions-cms-and-file-manager/#findComment-230737 Share on other sites More sharing options...
per1os Posted April 16, 2007 Share Posted April 16, 2007 try printing $sql on line 32 and see what happens. Link to comment https://forums.phpfreaks.com/topic/47296-helpadvice-with-group-permissions-cms-and-file-manager/#findComment-230753 Share on other sites More sharing options...
boo_lolly Posted April 16, 2007 Author Share Posted April 16, 2007 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. Link to comment https://forums.phpfreaks.com/topic/47296-helpadvice-with-group-permissions-cms-and-file-manager/#findComment-230756 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.