fantity Posted September 14, 2012 Share Posted September 14, 2012 Why am I getting this error? <?php $connect = mysql_connect("","",""); if (!$connect) { die("MySQL could not connect!"); } $DB = mysql_select_db(''); if(!$DB) { die("My SQL could not select Database!"); } //STEP 2 Declare Variables $Username = $_POST['username']; $Email = $_POST['email']; $Email1 = "@"; $Email_Check = strpos($Email,$Email1); $Password = $_POST['password']; $Re_Password = $_POST['re-password']; $Birth = $_POST['birth']; //STEP 3 Check To See If All Information Is Correct if($Username == "") { die("Opps! You don't enter a username!"); } if($Password == "" || $Re_Password == "") { die("Opps! You didn't enter one of your passwords!"); } if($Birth == "") { die("Opps! You never entered in your birth year!"); } if($Password != $Re_Password) { die("Ouch! Your passwords don't match! Try again."); } if($Email_Check === false) { die("Opps! That's not an email!"); } //STEP 4 Insert Information Into MySQL Database if(!mysql_query("INSERT INTO Users (email, username, password, birth) VALUES ('$Email', '$Username', '$Password', '$Birth')")) { die("We could not register you due to a mysql error (Contact the website owner if this continues to happen.)"); } $name = $_POST['username']; echo "Registered"; mkdir("files/" . $name); copy("cindex.php", "files/" . $name . "/index.php") or die("Unable to copy $old to $new."); ?> Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 14, 2012 Share Posted September 14, 2012 Post the actual error. Quote Link to comment Share on other sites More sharing options...
ManiacDan Posted September 15, 2012 Share Posted September 15, 2012 There is no syntax error in this code. The error you got will include a line number and a file name. Find that line in that file. Show us that line and the 10 lines above it. Also, "oops" is spelled like that. Quote Link to comment Share on other sites More sharing options...
fantity Posted September 16, 2012 Author Share Posted September 16, 2012 Post the actual error. Parse error: syntax error, unexpected T_STRING in login.php on line 36 Same code as before Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 16, 2012 Share Posted September 16, 2012 There is still no syntax error in that file. Quote Link to comment Share on other sites More sharing options...
jazzman1 Posted September 16, 2012 Share Posted September 16, 2012 Do you understand what does a piece of code mean? if(!mysql_query("INSERT INTO Users (email, username, password, birth) VALUES ('$Email', '$Username', '$Password', '$Birth')")) Quote Link to comment Share on other sites More sharing options...
fantity Posted September 16, 2012 Author Share Posted September 16, 2012 There is still no syntax error in that file. I don't know what's wrong here . $name = $_POST['username']; 60. echo "Registered"; 61. mkdir("files/" . $name); 62. copy("cindex.php", "files/" . $name . "/index.php") or die("Unable to copy $old to $new."); Error: Parse error: syntax error, unexpected T_STRING in register.php on line 62 Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted September 16, 2012 Share Posted September 16, 2012 Still no error in the posted code. Post the whole file, in the same state it's in when it causes the error. EDIT: Post it from the beginning to 5 lines past the error . . . Quote Link to comment Share on other sites More sharing options...
ManiacDan Posted September 16, 2012 Share Posted September 16, 2012 Are you in the right file? Quote Link to comment Share on other sites More sharing options...
fantity Posted September 16, 2012 Author Share Posted September 16, 2012 Still no error in the posted code. Post the whole file, in the same state it's in when it causes the error. EDIT: Post it from the beginning to 5 lines past the error . . . <?php $connect = mysql_connect("","",""); if (!$connect) { die("MySQL could not connect!"); } $DB = mysql_select_db('a3056964_due'); if(!$DB) { die("My SQL could not select Database!"); } //STEP 2 Declare Variables $Username = $_POST['username']; $Email = $_POST['email']; $Email1 = "@"; $Email_Check = strpos($Email,$Email1); $Password = $_POST['password']; $Re_Password = $_POST['re-password']; $Birth = $_POST['birth']; //STEP 3 Check To See If All Information Is Correct if($Username == "") { die("Opps! You don't enter a username!"); } if($Password == "" || $Re_Password == "") { die("Opps! You didn't enter one of your passwords!"); } if($Birth == "") { die("Opps! You never entered in your birth year!"); } if($Password != $Re_Password) { die("Ouch! Your passwords don't match! Try again."); } if($Email_Check === false) { die("Opps! That's not an email!"); } //STEP 4 Insert Information Into MySQL Database if(!mysql_query("INSERT INTO Users (email, username, password, birth) VALUES ('$Email', '$Username', '$Password', '$Birth')")) { die("We could not register you due to a mysql error (Contact the website owner if this continues to happen.)"); } $name = $_POST['username']; echo "Registered"; mkdir("files/" . $name); copy("cindex.php", "files/" . $name . "/index.php") or die("Unable to copy $old to $new."); ?> Am I missing a bracket or something? And yes this is the right file Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted September 16, 2012 Share Posted September 16, 2012 Still no errors in the posted code. How are you determining there's an error? Is this on a hosted site, or local? Are you sure the edited copy of the file is in the right location (directory)? Quote Link to comment Share on other sites More sharing options...
fantity Posted September 16, 2012 Author Share Posted September 16, 2012 Still no errors in the posted code. How are you determining there's an error? Is this on a hosted site, or local? Are you sure the edited copy of the file is in the right location (directory)? When I press register it gives me the error. I use a free webhost. And yes it's the right directory Quote Link to comment Share on other sites More sharing options...
jazzman1 Posted September 16, 2012 Share Posted September 16, 2012 What's happening if you try to delete line 62? Quote Link to comment Share on other sites More sharing options...
fantity Posted September 16, 2012 Author Share Posted September 16, 2012 What's happening if you try to delete line 62? Same error Quote Link to comment Share on other sites More sharing options...
jazzman1 Posted September 16, 2012 Share Posted September 16, 2012 Put this one on the top immediately after php open tag. <?php echo 'check'; exit; $connect = mysql_connect("","",""); etc...... Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 16, 2012 Share Posted September 16, 2012 Then you're editing the wrong file or not uploading the file. Quote Link to comment Share on other sites More sharing options...
ManiacDan Posted September 17, 2012 Share Posted September 17, 2012 You are most likely not in the file you think you're in. Does your host cache and/or accelerate your files? Quote Link to comment Share on other sites More sharing options...
fantity Posted September 17, 2012 Author Share Posted September 17, 2012 You are most likely not in the file you think you're in. Does your host cache and/or accelerate your files? No, here is the html code as well as the php code again. <html> <body> <link rel="stylesheet" type="text/css" href="style.css" /> <title>Register</title> <center> <h1>Register</h1> <br> <form action="register.php" method="POST"> Username: <input type="text" name="username" /></br> Password: <input type="password" name="password" /></br> Re-type Password: <input type="password" name="re-password" /></br> <br> <small>cAsE SeNSitIvE</small> <br> <br /> <br> <input type="submit" name="submit" value="Register" /> </form> <br> </head> <body> <br> </body> </html> <?php echo 'check'; exit; $connect = mysql_connect("","",""); if (!$connect) { die("MySQL could not connect!"); } $DB = mysql_select_db('a3056964_due'); if(!$DB) { die("My SQL could not select Database!"); } //STEP 2 Declare Variables $Username = $_POST['username']; $Password = $_POST['password']; $Re_Password = $_POST['re-password']; //STEP 3 Check To See If All Information Is Correct if($Username == "") { die("Opps! You don't enter a username!"); } if($Password == "" || $Re_Password == "") { die("Opps! You didn't enter one of your passwords!"); } if($Password != $Re_Password) { die("Ouch! Your passwords don't match! Try again."); } //STEP 4 Insert Information Into MySQL Database if(!mysql_query("INSERT INTO Users (email, username) VALUES ('$Username', '$Password')")) { die("We could not register you due to a mysql error (Contact the website owner if this continues to happen.)"); } $name = $_POST['username']; echo "Registered"; mkdir("files/" . $name); copy("cindex.php", "files/" . $name . "/index.php") or die("Unable to copy $old to $new."); ?> Quote Link to comment Share on other sites More sharing options...
fantity Posted September 17, 2012 Author Share Posted September 17, 2012 Also, if I take away mkdir and copy it works fine. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted September 17, 2012 Share Posted September 17, 2012 Why are you creating a new directory and index.php file every time there's a new registration anyhow? Quote Link to comment Share on other sites More sharing options...
ManiacDan Posted September 17, 2012 Share Posted September 17, 2012 Ok, for the last time, this can't possibly be the code. Look, I'll prove it. The very first line: echo 'check'; exit; That would exit the script with the word check. Every time. This is clearly not the code you're running in production. Quote Link to comment Share on other sites More sharing options...
fantity Posted September 18, 2012 Author Share Posted September 18, 2012 Why are you creating a new directory and index.php file every time there's a new registration anyhow? It is a file cloud website which makes a dir to store their files, the index.php that I am copying into that folder makes sure they can't use other people's folders and contains the file uploader etc. Quote Link to comment Share on other sites More sharing options...
premiso Posted September 18, 2012 Share Posted September 18, 2012 "Cloud" Fuggin buzz words. Quote Link to comment Share on other sites More sharing options...
ManiacDan Posted September 18, 2012 Share Posted September 18, 2012 That's usually not how cloud storage works. There's still no security on these files, even if index.php asks for a password. Still though, your script is fine. Quote Link to comment Share on other sites More sharing options...
fantity Posted September 18, 2012 Author Share Posted September 18, 2012 I changed the end of the script to this $name = $_POST['username']; if(!file_exists("files/" . $name)) { mkdir("files/" . $name); } if(!file_exists("files/" . $name . "/index.php")) { $old = "cindex.php"; $new = "files/" . $name . "/index.php"; copy($old, $new) or die("Unable to copy $old to $new."); } echo "Registered"; and I have no more errors Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.