[SOLVED]

Place for questions and answers for all newcomers and new coders. This is a free for all forum, no question is too stupid and to noob.
Post Reply
Hattrick
Posts: 38
Joined: Tue Jan 17, 2012 1:11 am

[SOLVED]

Post 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?
Last edited by Hattrick on Fri Jan 20, 2012 8:04 pm, edited 1 time in total.
Image
User avatar
SpiritWebb
Posts: 3107
Joined: Sun Jul 12, 2009 11:25 pm

Re: Small Question...

Post 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;
)
Image

Image
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Small Question...

Post 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;
} 
The indelible lord of tl;dr
User avatar
SpiritWebb
Posts: 3107
Joined: Sun Jul 12, 2009 11:25 pm

Re: Small Question...

Post by SpiritWebb »

Crap, I didn't even notice the non-use of the curly brace ( { )...woops...
Image

Image
Hattrick
Posts: 38
Joined: Tue Jan 17, 2012 1:11 am

Re: Small Question...

Post by Hattrick »

Thank you guys soo much. I am just a noob so I will progress and get better but for now thanks!
Image
Post Reply

Return to “Beginner Help and Support”