Page 1 of 1

[SOLVED]

Posted: Fri Jan 20, 2012 1:07 am
by Hattrick
Another small question:

Code: Select all

<?php
include connect.php
?>

<?php
$player = $_POST['player'];
$password = $_POST['password'];
$pass2 = $_POST['pass2'];
$player = strip_tags($player);
$email = $_POST('email');
$email = strip_tags($email);

if ($email == "")
(
echo "You didn't enter a email address!<br>";
echo "<A href 'register.php'>Go Back</a";
exit;
)
if ($password==$pass2)  
(

$isplayer="Select *from players where name='$player'";
$isplayer2=mysql_query($isplayer) or die ("could not query players table");
$isplayer3=mysql_fetch_array($isplayer2);

if[!$_post('password') || !$_POST('pass2'])
(
print "You did not enter a password!<br>";
echo "<A href='register.php'>Go Back</a";
exit;
)
else if ($isplayer3 ||strlen($player)>21 || strlen($player<1;
(
print "There is already a player with that username or the name you specifified is over 16characters or less than one chartacter<br>";
echo "<A href='register.php'>Go Back</a>";
)
else
(

$isaddress="Select *from players where email='$email'";
$isaddress2=mysql_query($isaddress) or die ("could not query for passwords");
$isplayer3=mysql_fetch_array($isplayer2);

if($isaddress)
(
print "There is already a player with that e-mail address<br>";
echo "<A href='register.php'>Go Back</a>"
exit;
)
else
($password=md5($password);
$sql = "INSERT into players(name, password, email, level, exper) VALUES ('$player', '$password', '$email', '1', '0')";
mysql_query($sql) or die ("Could not register");

print "Thank you for registering!";

)
)
)

else
(
print ("your passwords didn't match or you did not enter a password")
echo "<A href='register.php'>gGo Back</a>"
exit;
)
   Echo  "<A href='login.php'>Login Page</a>"
?>
is there something wrong with this code?
I checked the error and it said : " Parse error: syntax error, unexpected T_ECHO in C:\wamp\www\Tutorial\Reguser.php on line 15"
I checked line 15 and it's the same exact thing as in the tutorial and it still shows this error. Help?

Re: Small Question...

Posted: Fri Jan 20, 2012 3:43 am
by SpiritWebb
Hattrick wrote:Another small question:

Code: Select all

<?php
include connect.php
?>

<?php
$player = $_POST['player'];
$password = $_POST['password'];
$pass2 = $_POST['pass2'];
$player = strip_tags($player);
$email = $_POST('email');
$email = strip_tags($email);

if ($email == "")
(
echo "You didn't enter a email address!<br>";
echo "<A href 'register.php'>Go Back</a";
exit;
)
if ($password==$pass2)  
(

$isplayer="Select *from players where name='$player'";
$isplayer2=mysql_query($isplayer) or die ("could not query players table");
$isplayer3=mysql_fetch_array($isplayer2);

if[!$_post('password') || !$_POST('pass2'])
(
print "You did not enter a password!<br>";
echo "<A href='register.php'>Go Back</a";
exit;
)
else if ($isplayer3 ||strlen($player)>21 || strlen($player<1;
(
print "There is already a player with that username or the name you specifified is over 16characters or less than one chartacter<br>";
echo "<A href='register.php'>Go Back</a>";
)
else
(

$isaddress="Select *from players where email='$email'";
$isaddress2=mysql_query($isaddress) or die ("could not query for passwords");
$isplayer3=mysql_fetch_array($isplayer2);

if($isaddress)
(
print "There is already a player with that e-mail address<br>";
echo "<A href='register.php'>Go Back</a>"
exit;
)
else
($password=md5($password);
$sql = "INSERT into players(name, password, email, level, exper) VALUES ('$player', '$password', '$email', '1', '0')";
mysql_query($sql) or die ("Could not register");

print "Thank you for registering!";

)
)
)

else
(
print ("your passwords didn't match or you did not enter a password")
echo "<A href='register.php'>gGo Back</a>"
exit;
)
   Echo  "<A href='login.php'>Login Page</a>"
?>
is there something wrong with this code?
I checked the error and it said : " Parse error: syntax error, unexpected T_ECHO in C:\wamp\www\Tutorial\Reguser.php on line 15"
I checked line 15 and it's the same exact thing as in the tutorial and it still shows this error. Help?

Code: Select all

if ($email == "")
(
echo "You didn't enter a email address!<br>";
echo "<A href 'register.php'>Go Back</a";
exit;
)
You forgot the = so it should be:

Code: Select all


if ($email == "")
(
echo "You didn't enter a email address!<br>";
echo "<a href = 'register.php'>Go Back</a"; // <-- Fix this line
exit;
)

Re: Small Question...

Posted: Fri Jan 20, 2012 5:02 am
by Jackolantern
And you are using the wrong kind of braces for all of your IF statements and code blocks. This is a pretty common error, since it is hard to tell the difference in the tutorial videos.

Any IF statements, as you have right now:

Code: Select all

if ($email == "")
(
echo "You didn't enter a email address!<br>";
echo "<A href 'register.php'>Go Back</a";
exit;
) 
...will cause errors. You need to use curly braces like this:

Code: Select all

if ($email == "")
{
echo "You didn't enter a email address!<br>";
echo "<A href 'register.php'>Go Back</a";
exit;
} 

Re: Small Question...

Posted: Fri Jan 20, 2012 5:12 am
by SpiritWebb
Crap, I didn't even notice the non-use of the curly brace ( { )...woops...

Re: Small Question...

Posted: Fri Jan 20, 2012 4:19 pm
by Hattrick
Thank you guys soo much. I am just a noob so I will progress and get better but for now thanks!