Jump to content

Recommended Posts

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.");
  


?>



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.

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

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 . . .

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

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

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

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.");
  


?>



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.

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.

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  :wtf:

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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...

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.